Tirraa / dashboard_rtm

dashboard_rtm
MIT License
5 stars 1 forks source link

[Blog][Feature] Blog tags #15

Closed gustaveWPM closed 7 months ago

gustaveWPM commented 1 year ago

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 as string[] (?)

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 a BLOG_TAGS field, typed as a string[], in the config/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 with BLOG_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

gustaveWPM commented 1 year ago

Hmmm, seems that I was wrong. https://www.emmacampbell.dev/blog/blog-content-layer

Gonna check it someday.

gustaveWPM commented 11 months ago

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.

gustaveWPM commented 8 months ago

Implemented it on Contentlayer side. https://github.com/Tirraa/dashboard_rtm/pull/99

Now gonna implement it on the front-end side.

gustaveWPM commented 7 months ago

Done. https://github.com/Tirraa/dashboard_rtm/commit/05c9313e11ea7abebaa59c107ee4089063547ab5

gustaveWPM commented 7 months ago

Whoops, forgot the documentation, LOL

gustaveWPM commented 7 months ago

Docs: https://github.com/Tirraa/dashboard_rtm/commit/3f8e771258d3ba824ba50961c33031ed48dfbcee