Closed N0K0 closed 1 month ago
Thanks for reporting the issue? Do you mind providing a reproduction? You can use Nuxt Starter if you want to
Hi @farnabaz, the following is the smallest example I managed to make :) Only touched the index.md file to fill with some alternative content and the plugin https://stackblitz.com/edit/github-njqpgs?file=server%2Fplugins%2Fafter.ts
The log is different from when I last tried in November, but the final error is the same src.replace is not a function
Log:
{
_path: '/about',
_dir: '',
_draft: false,
_partial: false,
_locale: '',
title: 'About Content v2',
description: 'Back home',
excerpt: undefined,
body: {
type: 'root',
children: [ [Object], [Object] ],
toc: { title: '', searchDepth: 2, depth: 2, links: [] }
},
_type: 'markdown',
_id: 'content:about.md',
_source: 'content',
_file: 'about.md',
_extension: 'md'
}
[Vue warn]: Failed to resolve component:
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
{
_path: '/',
_dir: '',
_draft: false,
_partial: false,
_locale: '',
title: 'Index',
description: '',
excerpt: undefined,
body: {
type: 'root',
children: [ [Object], [Object], [Object], [Object] ],
toc: { title: '', searchDepth: 2, depth: 2, links: [Array] }
},
_type: 'markdown',
_id: 'content:index.md',
_source: 'content',
_file: 'index.md',
_extension: 'md'
}
[Vue warn]: Failed to resolve component:
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
[Vue warn]: Invalid vnode type when creating vnode: undefined.
[nuxt] [request error] [unhandled] [500] src.replace is not a function
[Vue warn]: Failed to resolve component:
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
[Vue warn]: Failed to resolve component:
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
[Vue warn]: Invalid vnode type when creating vnode: undefined.
[nuxt] [request error] [unhandled] [500] src.replace is not a function
I see, This happens because the modified tree is invalid. If you want to change a text into a code, you can do this:
if (file.body.children[2]?.children[2]) {
const link_node = {
type: 'element',
tag: 'code',
children: [
{
type: 'text',
value: 'test updated',
},
],
};
file.body.children[2].children[2] = link_node;
}
I have updated your reproduction: https://stackblitz.com/edit/github-njqpgs-yxn88u?file=server%2Fplugins%2Fafter.ts
Ah, interesting! Sorry for the slow response. I've been referring to the mdast spec https://github.com/syntax-tree/mdast?tab=readme-ov-file#code
Any place I can read about the structure Content expects? :)
The structure of MDC tree is very similar to HAST structure, except that MDC use tag
instead of tagName
and props
instead of properties
.
Checkout Hast docs here: https://github.com/syntax-tree/hast
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.
This issue was closed because it has been stalled for 30 days with no activity.
Discussed in https://github.com/nuxt/content/discussions/2411