Skip to content

Commit ec3c61f

Browse files
authored
fix(module): do not add vue files to ignore list (#1476)
* fix(module): do not add vue files to ignore list * test: add tests
1 parent ce5397d commit ec3c61f

6 files changed

Lines changed: 36 additions & 2 deletions

File tree

src/module.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,14 @@ export default defineNuxtModule<ModuleOptions>({
293293
for (const source of Object.values(sources)) {
294294
// Only targets directories inside the srcDir
295295
if (source.driver === 'fs' && source.base.includes(nuxt.options.srcDir)) {
296+
const wildcard = join(source.base, '**/*').replace(withTrailingSlash(nuxt.options.srcDir), '')
296297
nuxt.options.ignore.push(
297298
// Remove `srcDir` from the path
298-
join(source.base, '**/*').replace(withTrailingSlash(nuxt.options.srcDir), '')
299+
wildcard,
300+
`!${wildcard}.vue`
299301
)
300302
}
301303
}
302-
303304
nitroConfig.bundledStorage = nitroConfig.bundledStorage || []
304305
nitroConfig.bundledStorage.push('/cache/content')
305306

test/basic.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { testContentQuery } from './features/content-query'
1717
import { testHighlighter } from './features/highlighter'
1818
import { testMarkdownRenderer } from './features/renderer-markdown'
1919
import { testParserOptions } from './features/parser-options'
20+
import { testComponents } from './features/components'
2021

2122
const spyConsoleWarn = vi.spyOn(global.console, 'warn')
2223

@@ -99,6 +100,7 @@ describe('Basic usage', async () => {
99100
expect(html).contains('<meta property="og:image" content="https://picsum.photos/200/300">')
100101
expect(html).contains('<meta name="description" content="Description overwritten"><meta property="og:image" content="https://picsum.photos/200/300">')
101102
})
103+
102104
test('<ContentDoc> head management (not same path)', async () => {
103105
const html = await $fetch('/bypass-head')
104106
expect(html).not.contains('<title>Head overwritten</title>')
@@ -122,11 +124,14 @@ describe('Basic usage', async () => {
122124
expect(spyConsoleWarn).toHaveBeenCalledWith('Ignoring [content:with-\'invalid\'-char.md]. File name should not contain any of the following characters: \', ", ?, #, /')
123125
})
124126

127+
testComponents()
128+
125129
testContentQuery()
126130

127131
testNavigation()
128132

129133
testMarkdownParser()
134+
130135
testMarkdownRenderer()
131136

132137
testMarkdownParserExcerpt()

test/features/components.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { describe, test, expect } from 'vitest'
2+
import { $fetch } from '@nuxt/test-utils'
3+
4+
export const testComponents = () => {
5+
describe('components', () => {
6+
test('from content directory', async () => {
7+
const index = await $fetch('/components/from-content')
8+
9+
expect(index).toContain('Lorem ipsum dolor sit, amet consectetur adipisicing elit.')
10+
})
11+
})
12+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template>
2+
<p>
3+
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Asperiores tempore totam cum rerum natus aliquid cumque enim accusamus, dicta eveniet illum alias similique facilis blanditiis. Totam architecto a ratione earum.
4+
</p>
5+
</template>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Components inside content
2+
3+
::lorem-ipsum
4+
::

test/fixtures/basic/nuxt.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ export default defineNuxtConfig({
1313
{
1414
path: resolve(__dirname, './components'),
1515
global: true
16+
},
17+
{
18+
path: resolve(__dirname, './content'),
19+
global: true,
20+
pathPrefix: false,
21+
prefix: ''
1622
}
1723
]
1824
},
@@ -27,6 +33,7 @@ export default defineNuxtConfig({
2733
base: resolve(__dirname, 'content-fa')
2834
}
2935
],
36+
ignores: ['.*\\.vue'],
3037
navigation: {
3138
fields: ['icon']
3239
},

0 commit comments

Comments
 (0)