orchidhq / Orchid

Build and deploy beautiful documentation sites that grow with you
https://orchid.run
GNU General Public License v3.0
513 stars 53 forks source link

Accept /Year/Month/Day/Title/index.md and /Year/DaysOfYear-Title/index.md #361

Closed BrunoVernay closed 4 years ago

BrunoVernay commented 4 years ago

Accept /Year/Month/Day/Title/index.md and /Year/DaysOfYear-title/index.md (typically used in Gatsby)

BrunoVernay commented 4 years ago

I tried to find a RegEx that could remove the non-significant "-index" at the end. But I could not find one. This is why I ended up tweaking the getPostFilename() in PostUtils. Not the best design ... it may come as a surprise later for other use cases. If not RegEx, it would be very easy to remove an eventual "-index" in a string. All this code should be close together ideally. If you point me at some design I could try out better options.

cjbrooks12 commented 4 years ago

This solution is totally fine, I'm already doing a very similar thing in the Wiki plugin too.

Also, the functionality is working great, thank you for your help! The only question I have is not related to the functionality: you mentioned the /Year/DaysOfYear-title/index.md format is a Gatsby-style foramt, but I haven't ever really used Gatsby and can't find documentation for that with a quick search. Could you find me a link to documentation or examples from Gatsby, or add some brief documentation to the OrchidPosts/README.md describing this new format?

BrunoVernay commented 4 years ago

Ok, after searching, my only conclusion is that Gatsby does not care about folders and file names. It will take everything and use the frontmatter to get the information. The format seems to be mine https://gitlab.com/km-brnvrn/static-site/-/blob/master/new-post.sh like a compromise to get some structured folder organisation and ease of use.

From Orchid point of view, I may have added unnecessary complexity. Yet the current code put a constraint on the folder/file organization ...
For me, I could write a script that take my format on one side and create the Orchid expected files on the other.

cjbrooks12 commented 4 years ago

I'm OK with the additional complexity here; the regex itself is just an implementation detail, and I like the idea of relaxing the strict requirements on the filename structure. The main thing I want to make sure to keep is to determine the post date from the filename instead of from the Front Matter.

Thanks again for your work on this. I'm working on finishing up release notes for the next version now, and should hopefully have this all released sometime today.