diff --git a/src/module.ts b/src/module.ts index 94ec66344..759a9e045 100644 --- a/src/module.ts +++ b/src/module.ts @@ -287,13 +287,14 @@ export default defineNuxtModule({ for (const source of Object.values(sources)) { // Only targets directories inside the srcDir if (source.driver === 'fs' && source.base.includes(nuxt.options.srcDir)) { + const wildcard = join(source.base, '**/*').replace(withTrailingSlash(nuxt.options.srcDir), '') nuxt.options.ignore.push( // Remove `srcDir` from the path - join(source.base, '**/*').replace(withTrailingSlash(nuxt.options.srcDir), '') + wildcard, + `!${wildcard}.vue` ) } } - nitroConfig.bundledStorage = nitroConfig.bundledStorage || [] nitroConfig.bundledStorage.push('/cache/content') diff --git a/test/basic.test.ts b/test/basic.test.ts index f9f7d11cd..13ef606c2 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -17,6 +17,7 @@ import { testContentQuery } from './features/content-query' import { testHighlighter } from './features/highlighter' import { testMarkdownRenderer } from './features/renderer-markdown' import { testParserOptions } from './features/parser-options' +import { testComponents } from './features/components' const spyConsoleWarn = vi.spyOn(global.console, 'warn') @@ -99,6 +100,7 @@ describe('Basic usage', async () => { expect(html).contains('') expect(html).contains('') }) + test(' head management (not same path)', async () => { const html = await $fetch('/bypass-head') expect(html).not.contains('Head overwritten') @@ -122,11 +124,14 @@ describe('Basic usage', async () => { expect(spyConsoleWarn).toHaveBeenCalledWith('Ignoring [content:with-\'invalid\'-char.md]. File name should not contain any of the following characters: \', ", ?, #, /') }) + testComponents() + testContentQuery() testNavigation() testMarkdownParser() + testMarkdownRenderer() testMarkdownParserExcerpt() diff --git a/test/features/components.ts b/test/features/components.ts new file mode 100644 index 000000000..82370bda9 --- /dev/null +++ b/test/features/components.ts @@ -0,0 +1,12 @@ +import { describe, test, expect } from 'vitest' +import { $fetch } from '@nuxt/test-utils' + +export const testComponents = () => { + describe('components', () => { + test('from content directory', async () => { + const index = await $fetch('/components/from-content') + + expect(index).toContain('Lorem ipsum dolor sit, amet consectetur adipisicing elit.') + }) + }) +} diff --git a/test/fixtures/basic/content/LoremIpsum.vue b/test/fixtures/basic/content/LoremIpsum.vue new file mode 100644 index 000000000..113034a6b --- /dev/null +++ b/test/fixtures/basic/content/LoremIpsum.vue @@ -0,0 +1,5 @@ + diff --git a/test/fixtures/basic/content/components/from-content.md b/test/fixtures/basic/content/components/from-content.md new file mode 100644 index 000000000..3402c87e6 --- /dev/null +++ b/test/fixtures/basic/content/components/from-content.md @@ -0,0 +1,4 @@ +# Components inside content + +::lorem-ipsum +:: diff --git a/test/fixtures/basic/nuxt.config.ts b/test/fixtures/basic/nuxt.config.ts index e9ccd1924..44453437a 100644 --- a/test/fixtures/basic/nuxt.config.ts +++ b/test/fixtures/basic/nuxt.config.ts @@ -13,6 +13,12 @@ export default defineNuxtConfig({ { path: resolve(__dirname, './components'), global: true + }, + { + path: resolve(__dirname, './content'), + global: true, + pathPrefix: false, + prefix: '' } ] }, @@ -27,6 +33,7 @@ export default defineNuxtConfig({ base: resolve(__dirname, 'content-fa') } ], + ignores: ['.*\\.vue'], navigation: { fields: ['icon'] },