Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(logging): cleanup logging #1733

Merged
merged 2 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/content/3.guide/1.writing/8.vue-component.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Components usage

Content module allows you to use your custom Vue components inside markdown contents.

Components that are used in Markdown has to be marked as `global` in your Nuxt app.

## `components/content` directory

**@nuxt/content** provides a directory that will automatically mark your components as globals.

Every component created inside the `components/content` directory will be available in Markdown files.

- You can create any kind of component
- You can overwrite any existing components by following same naming
- Creating `components/content/ProseA.vue` will overwrite any other existing `ProseA.vue` component injected from a module or any [extends](https://nuxt.com/docs/api/configuration/nuxt-config/#extends) layer.

## Global components in Nuxt

All global components in your Nuxt app will be available to use in your markdown files.

For more information about global components, visit [Nuxt 3 docs](https://nuxt.com/docs/guide/directory-structure/components).
11 changes: 0 additions & 11 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,6 @@ export default defineNuxtModule<ModuleOptions>({
const globalComponents = resolve(srcDir, 'components/content')
const dirStat = await fs.promises.stat(globalComponents).catch(() => null)
if (dirStat && dirStat.isDirectory()) {
if (nuxt.options._layers.length === 1) {
logger.success('Using `~/components/content` for components in Markdown')
}
nuxt.hook('components:dirs', (dirs) => {
dirs.unshift({
path: globalComponents,
Expand All @@ -435,14 +432,6 @@ export default defineNuxtModule<ModuleOptions>({
prefix: ''
})
})
} else if (nuxt.options._layers.length === 1) {
const componentsDir = resolve(srcDir, 'components/')
const componentsDirStat = await fs.promises.stat(componentsDir).catch(() => null)
if (componentsDirStat && componentsDirStat.isDirectory()) {
// TODO: watch for file creation and tell Nuxt to restart
// Not possible for now since directories are hard-coded: https://github.com/nuxt/framework/blob/5b63ae8ad54eeb3cb49479da8f32eacc1a743ca0/packages/nuxi/src/commands/dev.ts#L94
logger.info('Please create `~/components/content` and restart the Nuxt server to use components in Markdown')
}
}
}

Expand Down