-
Hello, I need the raw content of the markdown file so that I can do customized parsing, but doesn't want to lose what I learned that I can use a customized import { defineTransformer } from "@nuxt/content/transformers";
export default defineTransformer({
name: "md-transformer",
extensions: [".md"],
parse(_id: string, rawContent: string) {
return {
_id,
body: rawContent.trim().split('\n').map(line => line.trim()).sort()
};
},
}); But this will totally change the returned object for |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Have you explored Nuxt Content hooks? They allow you to hook into states of the parsing process like // ~/server/plugins/content.ts
export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook('content:file:beforeParse', (file) => {
if (file._id.endsWith('.md')) {
file.body = file.body.replace(/react/g, 'vue')
}
})
}) |
Beta Was this translation helpful? Give feedback.
I tried, but somehow it doesn't work for me.
In the end I come up with this solution: