daviddarnes/netlify-plugin-ghost-markdown

Internal Tags

BryanSchuetz opened this issue · 5 comments

Internal tags (e.g. #an-internal-tag), don't escape the hash in the front matter. Which YAML is I think seeing as the beginning of a comment, and so it's throwing a YAML error. We could probably just quote each of the items in the tags array to get around this.

Oh dear, that's a bit of an issue. Not sure how to handle that though. Internal tags are designed for filtering content, not exposing on the front-end. Do you think it would be best if we apply them to the tags front matter but filter them out of the tag pages?

Fix would be along the lines of changing this line to use tag.slug instead of tag.name as I believe slug swaps # for hash-:
https://github.com/daviddarnes/netlify-plugin-ghost-markdown/blob/master/index.js#L120

…and then filtering out internal tags for tag pages here:
https://github.com/daviddarnes/netlify-plugin-ghost-markdown/blob/master/index.js#L430

Maybe with api.tags.filter(tag => !tag.name.startsWith("#")).

Ok that's enough rambling on, just put these notes for the person who gets there first 😊

Using tag.slug is an option I suppose. Main thing is to just make sure we have valid YAML/Markdown when everything is pulled down.

Related: including quotes in post title will also throw a YAML error because the quotes are not being escaped.

Switching to the slug is probably best as Ghost will handle the escaping effectively, as Ghost needs to do this with internal tags, hence why internal tag slugs are prefixed with hash-. I suppose the title needs to be escaped, but maybe escaping in your theme code will solve it?

I'm not using the files in a ghost theme. Ultimately, I think the markdown files generated by the plugin should have valid YAML in the front matter. So should probably escape the text before it ends up there. Here is a pull request for slugifying the tag names: #26

I've updated the plugin to 3.1.0 @BryanSchuetz and submitted the update to the Netlify Build Plugins directory. Here's hoping it all works ok as I removed the lock file, it was giving me grief about dependencies and I don't think there's enough changes happening for it to be an issue with versioning.

I really need to smooth out the development process of this plugin, I currently have a whole demo repo just to test it 😵