Closed gustaveWPM closed 7 months ago
Hmmm, seems that I was wrong. https://www.emmacampbell.dev/blog/blog-content-layer
Gonna check it someday.
Excellent implementation right here: https://github.com/thedevdavid/digital-garden/blob/main/lib/content-definitions/post.ts
No static analysis black art needed. It can be implemented "For free". This is supported by ContentLayer.
Implemented it on Contentlayer side. https://github.com/Tirraa/dashboard_rtm/pull/99
Now gonna implement it on the front-end side.
Whoops, forgot the documentation, LOL
Hi there!Until now I wasn't sure how to integrate blog tags while keeping a good DX, given that ContentLayer doesn't go further than typing them asstring[]
(?)That's a pretty awful notion of "Typesafe", given that you have no way of establishing a fixed list of tags to refer to and stick to.Now that the question of creating a tailor-made static analyzer that runs at the prebuild stage has been decided, and we've got a little PoC of it, I think it might be worth thinking about this feature again.We could consider creating aBLOG_TAGS
field, typed as astring[]
, in theconfig/blog.ts
file, and then add functionalities to the static analyzer so that it opens ALL.md*
files in the posts folder and analyzes whether the tags entered are valid, in accordance withBLOG_TAGS
. We can also gain some time for the.md*
files' header parsing, using gray-matter.It would also be possible to perform a pass on the default locale file (i18n) to ensure that all blog tag translations are properly declared.See: https://github.com/Tirraa/dashboard_rtm/issues/15#issuecomment-1831038256