prismicio / gatsby-source-prismic-graphql

Gatsby source plugin for Prismic GraphQL
MIT License
17 stars 14 forks source link

[Discussion] - support for more complex paths e.g. `/blog/:year/:month/:day/:uid` #37

Open matthewtgilbride opened 4 years ago

matthewtgilbride commented 4 years ago

My client's current website's blog is set up in this fashion.

From what I can tell, the only supported elements in the path are :lang and :uid, each of which is underneath the meta field.

If I have a blog_post Custom Type set up in prismic, I would like to have a field post_date, and then construct the url per the description of this issue /blog/:year/:month/:day/:uid

From what I can read this is not possible. Am I incorrect?

matthewtgilbride commented 4 years ago

@MarcMcIntosh see #38 - thoughts?

schwigri commented 4 years ago

Although not a solution for this plugin, you can use Gatsby's gatsby-node to define more complex paths for certain items.

Note that Prismic fields aside from UID are not strictly enforced, so you could end up with a post that does not have the post_date field set (which you should account for).

Prismic does have firstPublicationDate and lastPublicationDate fields always available under _meta so that may be safer to use.

ohlr commented 4 years ago

I saw that first publication date is undefined when previewing a page - using that may brake previews