mirror of https://github.com/vuejs/vitepress
commit
d2840dc100
@ -1,8 +1,14 @@
|
||||
export default {
|
||||
async paths() {
|
||||
return [
|
||||
{ params: { id: 'foo' }, content: `# Foo` },
|
||||
{ params: { id: 'bar' }, content: `# Bar` }
|
||||
]
|
||||
import { defineRoutes } from 'vitepress'
|
||||
import paths from './paths'
|
||||
|
||||
export default defineRoutes({
|
||||
async paths(watchedFiles: string[]) {
|
||||
// console.log('watchedFiles', watchedFiles)
|
||||
return paths
|
||||
},
|
||||
watch: ['**/data-loading/**/*.json'],
|
||||
async transformPageData(pageData) {
|
||||
// console.log('transformPageData', pageData.filePath)
|
||||
pageData.title += ' - transformed'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -0,0 +1,4 @@
|
||||
export default [
|
||||
{ params: { id: 'foo' }, content: `# Foo` },
|
||||
{ params: { id: 'bar' }, content: `# Bar` }
|
||||
]
|
@ -0,0 +1,27 @@
|
||||
# header 1
|
||||
|
||||
header 1 content
|
||||
|
||||
## header 1.1
|
||||
|
||||
header 1.1 content
|
||||
|
||||
### header 1.1.1
|
||||
|
||||
header 1.1.1 content
|
||||
|
||||
### header 1.1.2
|
||||
|
||||
header 1.1.2 content
|
||||
|
||||
## header 1.2
|
||||
|
||||
header 1.2 content
|
||||
|
||||
### header 1.2.1
|
||||
|
||||
header 1.2.1 content
|
||||
|
||||
### header 1.2.2
|
||||
|
||||
header 1.2.2 content
|
@ -0,0 +1,72 @@
|
||||
import { ModuleGraph } from 'node/utils/moduleGraph'
|
||||
|
||||
describe('node/utils/moduleGraph', () => {
|
||||
let graph: ModuleGraph
|
||||
|
||||
beforeEach(() => {
|
||||
graph = new ModuleGraph()
|
||||
})
|
||||
|
||||
it('should correctly delete a module and its dependents', () => {
|
||||
graph.add('A', ['B', 'C'])
|
||||
graph.add('B', ['D'])
|
||||
graph.add('C', [])
|
||||
graph.add('D', [])
|
||||
|
||||
expect(graph.delete('D')).toEqual(new Set(['D', 'B', 'A']))
|
||||
})
|
||||
|
||||
it('should handle shared dependencies correctly', () => {
|
||||
graph.add('A', ['B', 'C'])
|
||||
graph.add('B', ['D'])
|
||||
graph.add('C', ['D']) // Shared dependency
|
||||
graph.add('D', [])
|
||||
|
||||
expect(graph.delete('D')).toEqual(new Set(['A', 'B', 'C', 'D']))
|
||||
})
|
||||
|
||||
it('merges dependencies correctly', () => {
|
||||
// Add module A with dependency B
|
||||
graph.add('A', ['B'])
|
||||
// Merge new dependency C into module A (B should remain)
|
||||
graph.add('A', ['C'])
|
||||
|
||||
// Deleting B should remove A as well, since A depends on B.
|
||||
expect(graph.delete('B')).toEqual(new Set(['B', 'A']))
|
||||
})
|
||||
|
||||
it('handles cycles gracefully', () => {
|
||||
// Create a cycle: A -> B, B -> C, C -> A.
|
||||
graph.add('A', ['B'])
|
||||
graph.add('B', ['C'])
|
||||
graph.add('C', ['A'])
|
||||
|
||||
// Deleting any module in the cycle should delete all modules in the cycle.
|
||||
expect(graph.delete('A')).toEqual(new Set(['A', 'B', 'C']))
|
||||
})
|
||||
|
||||
it('cleans up dependencies when deletion', () => {
|
||||
// Setup A -> B relationship.
|
||||
graph.add('A', ['B'])
|
||||
graph.add('B', [])
|
||||
|
||||
// Deleting B should remove both B and A from the graph.
|
||||
expect(graph.delete('B')).toEqual(new Set(['B', 'A']))
|
||||
|
||||
// After deletion, add modules again.
|
||||
graph.add('C', [])
|
||||
graph.add('A', ['C']) // Now A depends only on C.
|
||||
|
||||
expect(graph.delete('C')).toEqual(new Set(['C', 'A']))
|
||||
})
|
||||
|
||||
it('handles independent modules', () => {
|
||||
// Modules with no dependencies.
|
||||
graph.add('X', [])
|
||||
graph.add('Y', [])
|
||||
|
||||
// Deletion of one should only remove that module.
|
||||
expect(graph.delete('X')).toEqual(new Set(['X']))
|
||||
expect(graph.delete('Y')).toEqual(new Set(['Y']))
|
||||
})
|
||||
})
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
@ -0,0 +1 @@
|
||||
../../art/vitepress-logo.svg
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 33 B |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 33 B |
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue