diff --git a/nuxtjs.org/components/Alert.vue b/nuxtjs.org/components/Alert.vue index 943cf0612..f23be4de3 100644 --- a/nuxtjs.org/components/Alert.vue +++ b/nuxtjs.org/components/Alert.vue @@ -13,9 +13,8 @@ diff --git a/src/core/runtime/components/Markdown.ts b/src/core/runtime/components/Markdown.ts new file mode 100644 index 000000000..5c2b14fd1 --- /dev/null +++ b/src/core/runtime/components/Markdown.ts @@ -0,0 +1,21 @@ +import { flatUnwrap } from '~docus/utils' + +export default { + name: 'Markdown', + functional: true, + render: (_h, ctx) => { + const slot = ctx.props.slot || 'default' + let node = ctx.props.node || ctx.parent.$scopedSlots[slot] || ctx.parent.$slots[slot] + if (typeof node === 'function') { + node = node() + } + if (typeof node === 'string') { + return [node] + } + if (node && ctx.props.unwrap) { + const tags = ctx.props.unwrap.split(/[,\s]/) + node = flatUnwrap(node, tags) + } + return node + } +} diff --git a/src/core/runtime/components/index.ts b/src/core/runtime/components/index.ts new file mode 100644 index 000000000..048a1132d --- /dev/null +++ b/src/core/runtime/components/index.ts @@ -0,0 +1,7 @@ +import Vue from 'vue' + +import Markdown from '~docus/components/Markdown' +import DocusContent from '~docus/components/DocusContent' + +Vue.component('Markdown', Markdown) +Vue.component('DocusContent', DocusContent) diff --git a/src/core/runtime/utils.ts b/src/core/runtime/utils.ts index d8b5636a8..c9c5a25f2 100644 --- a/src/core/runtime/utils.ts +++ b/src/core/runtime/utils.ts @@ -18,26 +18,6 @@ export const expandTags = (_tags: string[]) => _tags.flatMap(t => TAGS_MAP[t]) */ export const TEXT_TAGS = expandTags(['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'li']) -// @vue/component -export const Markdown = { - functional: true, - render: (_h, ctx) => { - const slot = ctx.props.slot || 'default' - let node = ctx.props.node || ctx.parent.$scopedSlots[slot] || ctx.parent.$slots[slot] - if (typeof node === 'function') { - node = node() - } - if (typeof node === 'string') { - return [node] - } - if (node && ctx.props.unwrap) { - const tags = ctx.props.unwrap.split(/[,\s]/) - node = flatUnwrap(node, tags) - } - return node - } -} - /** * Check virtual node's tag * @param vnode Virtuel node from Vue virtual DOM diff --git a/src/defaultTheme/components/atoms/Alert.vue b/src/defaultTheme/components/atoms/Alert.vue index c96842e31..10bcfc7b8 100644 --- a/src/defaultTheme/components/atoms/Alert.vue +++ b/src/defaultTheme/components/atoms/Alert.vue @@ -10,10 +10,8 @@