Don't render frontmatter for chapters of type "slides" and use standard .md extension #51
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #32
This PR does two things:
type
value in a chapter's frontmatter. If it is"slides"
then it goes to the<Slides>
component; anything else goes to the standard<ContentRenderer>
used by NuxtContent.This is the result of trying many different ways of achieving this (various examples in Nuxt docs simply don't work as advertised or are too vaguely explained to know why things are silently failing, NuxtContent plugin does not make the raw markdown available after parsing and annoyingly ignores all custom props you might attempt to add in a custom plugin (see e.g. nuxt/content#2056), reveal.js does not want to add the functionality to ignore frontmatter etc etc) so this is the least hacky way I've come up with so far.
Something we should still solve (or clearly put in the documentation if not) regards the way the frontmatter is removed. Currently I regex for the first occurrence of text between "---" separators. As this is the same as the default reveal.js slide separator, there is potential for confusion if users forget to add frontmatter to their chapters (or misformat it somehow) and wonder why the first slide of their presentation is missing. We can either change the default, document it clearly or make the
stripFrontmatter()
function more intelligent. Not sure what is best.Note that there are node packages that claim to do the stripping but https://www.npmjs.com/package/front-matter is unmaintained and the replacement, https://www.npmjs.com/package/gray-matter, also seems no longer maintained. I did try gray-matter but got some cryptic error that I think is to do with it assuming it runs in a browser, so breaks when we do SSR. Not sure though.
Anyway, for now it seems to be working, at least locally. We should now test with deployment.