Use Custom Elements in MDC
mainTo use custom elements (tags that are not Vue components) within MDC markdown, you must configure them in two places to ensure both the Vue compiler and the MDC runtime treat them correctly:
- MDC Runtime: Add the tags to
mdc.components.customElementsinnuxt.config.ts. This prevents MDC from trying to resolve them as Vue components. - Vue Compiler: Add the tags to
vue.compilerOptions.isCustomElementinnuxt.config.tsso the Vue compiler doesn't warn about unknown components.
If you only provide mdc.components.customElements, MDC will automatically attempt to configure Vue for you.
export default defineNuxtConfig({
vue: {
compilerOptions: {
isCustomElement: (tag) => tag.startsWith('mjx')
}
},
mdc: {
components: {
customElements: ['mjx-container']
}
}
})