diff --git a/docs/content/1.get-started/1.installation.md b/docs/content/1.get-started/1.installation.md
index a5a0443f6..1c8f7a642 100644
--- a/docs/content/1.get-started/1.installation.md
+++ b/docs/content/1.get-started/1.installation.md
@@ -1,6 +1,6 @@
# Installation
-> Setting up a beautiful website with Docus is one command away. ðĪ
+Setting up a beautiful website with Docus is one command away. ðĪ
Docus is an opinionated [Nuxt](https://nuxtjs.org) application that allows you to generate **content-based websites** with ease.
diff --git a/docs/content/1.get-started/2.configuration.md b/docs/content/1.get-started/2.configuration.md
index d91b9ef75..d6158403d 100644
--- a/docs/content/1.get-started/2.configuration.md
+++ b/docs/content/1.get-started/2.configuration.md
@@ -1,6 +1,6 @@
# Configuration
-> Tailor Docus for your own identity easily. ð
+Tailor Docus for your own identity easily. ð
## Website
diff --git a/docs/content/2.writing/1.my-first-page.md b/docs/content/2.writing/1.my-first-page.md
index 33b7f8884..8c9cc6bcd 100644
--- a/docs/content/2.writing/1.my-first-page.md
+++ b/docs/content/2.writing/1.my-first-page.md
@@ -5,7 +5,7 @@ navigation:
# Writing my first page
-> The fastest path to writing your content. ð
+The fastest path to writing your content. ð
Let's walk through the creation of a simple introduction page.
diff --git a/docs/content/2.writing/2.syntax.md b/docs/content/2.writing/2.syntax.md
index 81f8e2437..21368e01a 100644
--- a/docs/content/2.writing/2.syntax.md
+++ b/docs/content/2.writing/2.syntax.md
@@ -1,6 +1,6 @@
# Syntax
-> Docus syntax makes you love your components even more. ðĪ
+Docus syntax makes you love your components even more. ðĪ
Docus writing experience is based on a specific syntax built upon Vue components.
diff --git a/docs/content/2.writing/3.front-matter.md b/docs/content/2.writing/3.front-matter.md
index 9f98f786a..522491396 100644
--- a/docs/content/2.writing/3.front-matter.md
+++ b/docs/content/2.writing/3.front-matter.md
@@ -1,6 +1,6 @@
# Front-matter
-> Easily configure the rendering of your Markdown pages. ð
+Easily configure the rendering of your Markdown pages. ð
Front-matter is used to transmit data to your components and templates, from any page or directory.
@@ -42,7 +42,7 @@ The **title** and **description** are automatically filled in from the Markdown
```md
# Title of the page
-> Description of the page
+Description of the page
```
You can overwrite them using the Front-matter:
@@ -55,7 +55,7 @@ description: Overwritten description
# Title of the page
-> Description of the page
+Description of the page
```
## Inheritance
diff --git a/docs/content/2.writing/4.prose.md b/docs/content/2.writing/4.prose.md
index e334cfa73..3e751ee48 100644
--- a/docs/content/2.writing/4.prose.md
+++ b/docs/content/2.writing/4.prose.md
@@ -1,6 +1,6 @@
# Prose
-> Customizing your Markdown rendering has never been easier. ð§ââïļ
+Customizing your Markdown rendering has never been easier. ð§ââïļ
Docus Markdown rendering preserves the HTML structure of your file.
diff --git a/docs/content/3.features/1.routing.md b/docs/content/3.features/1.routing.md
index a185f63a3..9467eef7e 100644
--- a/docs/content/3.features/1.routing.md
+++ b/docs/content/3.features/1.routing.md
@@ -1,6 +1,6 @@
# Filesystem routing
-> A good looking website from any directory. ðŪ
+A good looking website from any directory. ðŪ
Each markdown page in the `contentDir` directory will become a page and will be listed in the left navigation.
diff --git a/docs/content/3.features/2.localization.md b/docs/content/3.features/2.localization.md
index 439aff674..aa3cdc848 100644
--- a/docs/content/3.features/2.localization.md
+++ b/docs/content/3.features/2.localization.md
@@ -1,6 +1,6 @@
# Localization
-> Enable i18n just by creating a directory. ðš
+Enable i18n just by creating a directory. ðš
The first level of directories in the `content/` folder are the locales used with [nuxt-i18n](https://github.com/nuxt-community/i18n-module) as defined in your `nuxt.config.js`.
diff --git a/docs/content/3.features/3.assets.md b/docs/content/3.features/3.assets.md
index a1dc898b0..70b2fd03f 100644
--- a/docs/content/3.features/3.assets.md
+++ b/docs/content/3.features/3.assets.md
@@ -1,6 +1,6 @@
# Assets
-> Easily import and optimize your assets with pre-defined modules. ð
+Easily import and optimize your assets with pre-defined modules. ð
## Favicon and PWA Icon
diff --git a/docs/content/3.features/4.social-image.md b/docs/content/3.features/4.social-image.md
index 7756a3828..5fd719aa6 100644
--- a/docs/content/3.features/4.social-image.md
+++ b/docs/content/3.features/4.social-image.md
@@ -1,6 +1,6 @@
# Social Images
-> Docus automatically generates a social preview image for every document. ðĪģ
+Docus automatically generates a social preview image for every document. ðĪģ
It uses the `social-image-preview` page to generate the images.
diff --git a/docs/content/3.features/5.deployment.md b/docs/content/3.features/5.deployment.md
index 4a865451d..9021f5de9 100644
--- a/docs/content/3.features/5.deployment.md
+++ b/docs/content/3.features/5.deployment.md
@@ -1,6 +1,6 @@
# Deployment
-> Deploy your documentation with Docus to any static hosting. ðŠķ
+Deploy your documentation with Docus to any static hosting. ðŠķ
To generate the documentation for production, run the following command:
diff --git a/docs/content/3.features/6.extend.md b/docs/content/3.features/6.extend.md
index 9461bd020..3c9cca50d 100644
--- a/docs/content/3.features/6.extend.md
+++ b/docs/content/3.features/6.extend.md
@@ -1,6 +1,6 @@
# Extend
-> Extend Docus with the power of Nuxt modules. ð
+Extend Docus with the power of Nuxt modules. ð
Docus is based on Nuxt, so you can benefit from the existing ecosystem of [Nuxt Modules](https://modules.nuxtjs.org/).
diff --git a/docs/content/3.features/7.migration.md b/docs/content/3.features/7.migration.md
index 84ed5944a..5e8046cef 100644
--- a/docs/content/3.features/7.migration.md
+++ b/docs/content/3.features/7.migration.md
@@ -5,7 +5,7 @@ navigation:
# Migrate from @nuxt/content-theme-docs
-> Migrate from @nuxt/content-theme-docs to Docus. ð
+Migrate from @nuxt/content-theme-docs to Docus. ð
By migrating to Docus, you will have a fresh new design for your documentation :sparkles:
diff --git a/docs/content/4.theme/1.settings.md b/docs/content/4.theme/1.settings.md
index 4f592a94e..6cf879c30 100644
--- a/docs/content/4.theme/1.settings.md
+++ b/docs/content/4.theme/1.settings.md
@@ -5,7 +5,7 @@ navigation:
# Theme settings
-> The default theme is entirely customizable, from a simple configuration file! âĻ
+The default theme is entirely customizable, from a simple configuration file! âĻ
The default configuration sets defaults for every needed feature of your theme.
diff --git a/docs/content/4.theme/2.components.md b/docs/content/4.theme/2.components.md
index 2d75e8f18..ebe3abc3e 100644
--- a/docs/content/4.theme/2.components.md
+++ b/docs/content/4.theme/2.components.md
@@ -1,6 +1,6 @@
# Components
-> Good looking components, ready to use in your website. ð
+Good looking components, ready to use in your website. ð
Docus default theme comes with a lot of pre-defined components.
diff --git a/docs/content/4.theme/5.layout.md b/docs/content/4.theme/5.layout.md
index cd6adcf94..5d4c79225 100644
--- a/docs/content/4.theme/5.layout.md
+++ b/docs/content/4.theme/5.layout.md
@@ -1,6 +1,6 @@
# Layout
-> Customize your website with slots or overwrite the layout components. ð§Đ
+Customize your website with slots or overwrite the layout components. ð§Đ
With the power of the [Nuxt Components](https://github.com/nuxt/components#overwriting-components), every part of the template is fully customizable.
diff --git a/docs/content/4.theme/6.slots.md b/docs/content/4.theme/6.slots.md
index d45c15af0..fddedf9ef 100644
--- a/docs/content/4.theme/6.slots.md
+++ b/docs/content/4.theme/6.slots.md
@@ -1,6 +1,6 @@
# Slots
-> Docus supports customizable slots in the template. ð§ą
+Docus supports customizable slots in the template. ð§ą
Just create a component inside your `components` directory with the same name as the slot.
diff --git a/src/core/runtime/components/NuxtContent.vue b/src/core/runtime/components/DocusContent.vue
similarity index 94%
rename from src/core/runtime/components/NuxtContent.vue
rename to src/core/runtime/components/DocusContent.vue
index c3b2adfd2..ede23f4ea 100644
--- a/src/core/runtime/components/NuxtContent.vue
+++ b/src/core/runtime/components/DocusContent.vue
@@ -148,20 +148,27 @@ function getSlotName(node) {
}
export default {
- name: 'NuxtContent',
+ name: 'DocusContent',
functional: true,
props: {
document: {
- type: Object,
+ type: [Object, String],
required: true
}
},
- render(h, { data, props, parent }) {
+ render(h, { data, props, parent, _v }) {
const { document } = props
+
+ // Render simple string
+ if (typeof document === 'string') {
+ return _v(document)
+ }
+
const { body } = document || {}
if (!body || !body.children || !Array.isArray(body.children)) {
return
}
+
let classes = []
if (Array.isArray(data.class)) {
classes = data.class
@@ -171,7 +178,7 @@ export default {
} else {
classes = [data.class]
}
- data.class = classes.concat('nuxt-content')
+ data.class = classes
data.props = Object.assign({ ...body.props }, data.props)
const children = body.children.map(child => processNode(child, h, document))
@@ -184,7 +191,11 @@ export default {
}
})
}
- return h('div', data, children)
+
+ // detect root tag
+ const tag = body.tag || 'div'
+
+ return h(tag, data, children)
}
}
diff --git a/src/core/utils/document.ts b/src/core/utils/document.ts
index 2bc52f849..7a694be3f 100644
--- a/src/core/utils/document.ts
+++ b/src/core/utils/document.ts
@@ -1,6 +1,6 @@
import { withoutTrailingSlash } from 'ufo'
import { DocusDocument, DocusMarkdownNode } from '../../types'
-import { expandTags } from '../runtime/utils'
+import { expandTags, flatUnwrap } from '../runtime/utils'
export function generatePosition(path: string, document: DocusDocument): string {
const position = path
@@ -33,9 +33,9 @@ export function isDraft(path: string): boolean {
}
export function processDocumentInfo(document: DocusDocument): DocusDocument {
- if (document.title && document.description) {
- return document
- }
+ // There is no need to extract if both title and descriptio is provided by user
+ if (document.title && document.description) return document
+
const [first, second] = document.body.children
// top level `text` can be ignored
.filter(node => node.type !== 'text')
@@ -43,28 +43,46 @@ export function processDocumentInfo(document: DocusDocument): DocusDocument {
if (first && expandTags(['h1']).includes(first.tag)) {
if (!document.title) {
document.title = getTextContent(first)
- Object.assign(first, {
- type: 'text',
- value: ''
- })
+ // Remove anchor link
+ first.children = flatUnwrap(first.children, ['a'])
+
+ document.titleNode = { body: first }
+
+ // Remove node if heading extract is enables
+ if (document.extract?.heading !== false) {
+ Object.assign(first, {
+ type: 'text',
+ value: ''
+ })
+ }
}
// look for second element to find description
- if (second && expandTags(['blockquote']).includes(second.tag)) {
+ if (second && expandTags(['p']).includes(second.tag)) {
if (!document.description) {
document.description = getTextContent(second)
- Object.assign(second, {
- type: 'text',
- value: ''
- })
+ document.descriptionNode = { body: second }
+
+ // Remove node if heading extract is enables
+ if (document.extract?.heading !== false) {
+ Object.assign(second, {
+ type: 'text',
+ value: ''
+ })
+ }
}
}
- } else if (first && first.type === 'blockquote') {
+ } else if (first && expandTags(['p']).includes(first.tag)) {
if (!document.description) {
document.description = getTextContent(first)
- Object.assign(first, {
- type: 'text',
- value: ''
- })
+ document.descriptionNode = { body: first }
+
+ // Remove node if heading extract is enables
+ if (document.extract?.heading !== false) {
+ Object.assign(first, {
+ type: 'text',
+ value: ''
+ })
+ }
}
}
return document
@@ -77,7 +95,7 @@ function getTextContent(node: DocusMarkdownNode): string {
if (node.children) {
text = text + node.children.map(child => getTextContent(child)).join('')
}
- return text
+ return text.trim()
}
function padLeft(value: string, length: number): string {
diff --git a/src/defaultTheme/components/atoms/InjectContent.vue b/src/defaultTheme/components/atoms/InjectContent.vue
index 89654b747..46c04fd29 100644
--- a/src/defaultTheme/components/atoms/InjectContent.vue
+++ b/src/defaultTheme/components/atoms/InjectContent.vue
@@ -1,5 +1,5 @@
-