@@ -121,6 +121,46 @@ describe("compileMemoryWikiVault", () => {
121121 ) . resolves . toContain ( '"text":"Alpha is the canonical source page."' ) ;
122122 } ) ;
123123
124+ it ( "discovers pages in nested subdirectories during compile" , async ( ) => {
125+ const { rootDir, config } = await createVault ( {
126+ rootDir : nextCaseRoot ( ) ,
127+ initialize : true ,
128+ } ) ;
129+
130+ await fs . mkdir ( path . join ( rootDir , "sources" , "sub" ) , { recursive : true } ) ;
131+ await fs . writeFile (
132+ path . join ( rootDir , "sources" , "top.md" ) ,
133+ renderWikiMarkdown ( {
134+ frontmatter : { pageType : "source" , id : "source.top" , title : "Top Source" } ,
135+ body : "# Top Source\n" ,
136+ } ) ,
137+ "utf8" ,
138+ ) ;
139+ await fs . writeFile (
140+ path . join ( rootDir , "sources" , "sub" , "nested.md" ) ,
141+ renderWikiMarkdown ( {
142+ frontmatter : { pageType : "source" , id : "source.nested" , title : "Nested Source" } ,
143+ body : "# Nested Source\n" ,
144+ } ) ,
145+ "utf8" ,
146+ ) ;
147+
148+ const result = await compileMemoryWikiVault ( config ) ;
149+
150+ expect ( result . pageCounts . source ) . toBe ( 2 ) ;
151+ // Root index should link to both
152+ await expect ( fs . readFile ( path . join ( rootDir , "index.md" ) , "utf8" ) ) . resolves . toContain (
153+ "[Top Source](sources/top.md)" ,
154+ ) ;
155+ await expect ( fs . readFile ( path . join ( rootDir , "index.md" ) , "utf8" ) ) . resolves . toContain (
156+ "[Nested Source](sources/sub/nested.md)" ,
157+ ) ;
158+ // Sources index should link to nested file
159+ await expect ( fs . readFile ( path . join ( rootDir , "sources" , "index.md" ) , "utf8" ) ) . resolves . toContain (
160+ "[Nested Source](sub/nested.md)" ,
161+ ) ;
162+ } ) ;
163+
124164 it ( "renders native directory index links relative to each generated index" , async ( ) => {
125165 const { rootDir, config } = await createVault ( {
126166 rootDir : nextCaseRoot ( ) ,
0 commit comments