[prismic]Automatically set uid for Heddless CMS prismic.

PRISMIC is a start-up technology company based in Paris and San Francisco.

The Heddles CMS provided was interesting, and the ability to have fields and type definitions on the server side and manage them with Git was attractive.
The disadvantage is that prismic has its own language and way of thinking, so you need to read the documentation carefully.

In this article, I will write about the UIDs assigned to each PRISMIC document.

目次

UID of Prismic

The UID field is a unique identifier used to create an SEO-friendly website URL.
This means that it ensures that no two documents have the same UID.

If you enter text in the UID field, Prismic automatically formats the text and verifies whether it is unique.
If you do not enter a UID, the text in another text field will be formatted and automatically populated.

If the value of a particular field is treated as a UID

In the customtypes index.json, add useAsTitle: true for the fields you want to treat as UIDs.

When the value of a field with useAsTitle set is entered, it will automatically be formatted as a UID.

      "title": {
        "type": "Text",
        "config": {
          "label": "タイトル",
          "placeholder": "",
          "useAsTitle": true
        }
      },

Automatic UID entry does not work.

Investigated the possibility of automatically assigning a numerical sequential number, like the PostID in WordPress.
But there doesn’t seem to be a way to automatically add UIDs at the moment.

For example, if you have a ‘title’ text field with useAsTitle set and enter alphanumeric characters, the UID is automatically set.
Well, it is easy to use.

But if you enter a Japanese string in the ‘title’ text field, the UID is not automatically set.

Apparently, the UID does not have Japanese language support.

In order to be operational, it may be necessary to establish some input rules for UIDs.

Summary

It seems a bit difficult if you expect to use it without being aware of UIDs, as is the case with WordPress.
It is attractive to be able to define and manage fields and types in Git, but it would be better if Japanese could also be supported. (It would be best if UIDs could be handled like IDENTITY.)

よかったらシェアしてね!
目次