-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from esciencecenter-digital-skills/fix_slides_…
…metadata Don't render frontmatter for chapters of type "slides" and use standard .md extension
- Loading branch information
Showing
3 changed files
with
47 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// This plugin is needed to solve the current bad implementation of NuxtContent | ||
// that only makes the post-processed markdown available in body and drops | ||
// other props (added e.g. during beforeParse) so the raw markdown cannot simply | ||
// be passed as a custom property. | ||
// | ||
// Check e.g. https://github.com/nuxt/content/issues/2056 to see if this | ||
// eventually gets fixed. | ||
|
||
// The following code is the workaround proposed here: | ||
// https://github.com/nuxt/content/issues/2056#issuecomment-1560200992 | ||
export default defineNitroPlugin((nitroApp) => { | ||
|
||
let files = {} | ||
|
||
nitroApp.hooks.hook("content:file:beforeParse", (file) => { | ||
if (file._id.endsWith(".md")) { | ||
files[file._id] = file.body; | ||
} | ||
}) | ||
|
||
nitroApp.hooks.hook("content:file:afterParse", (file) => { | ||
if (file._id.endsWith(".md")) { | ||
file.plainText = files[file._id]; | ||
} | ||
}) | ||
}); |