feat: implement getDependencyGraph for FolderPage (#849)

This commit is contained in:
kabirgh 2024-02-16 00:50:33 +00:00 committed by GitHub
parent 6c8023463d
commit 78a408c96a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -38,12 +38,21 @@ export const FolderPage: QuartzEmitterPlugin<Partial<FullPageLayout>> = (userOpt
getQuartzComponents() { getQuartzComponents() {
return [Head, Header, Body, ...header, ...beforeBody, pageBody, ...left, ...right, Footer] return [Head, Header, Body, ...header, ...beforeBody, pageBody, ...left, ...right, Footer]
}, },
async getDependencyGraph(_ctx, _content, _resources) { async getDependencyGraph(_ctx, content, _resources) {
// Example graph: // Example graph:
// nested/file.md --> nested/file.html // nested/file.md --> nested/index.html
// \-------> nested/index.html // nested/file2.md ------^
// TODO implement const graph = new DepGraph<FilePath>()
return new DepGraph<FilePath>()
content.map(([_tree, vfile]) => {
const slug = vfile.data.slug
const folderName = path.dirname(slug ?? "") as SimpleSlug
if (slug && folderName !== "." && folderName !== "tags") {
graph.addEdge(vfile.data.filePath!, joinSegments(folderName, "index.html") as FilePath)
}
})
return graph
}, },
async emit(ctx, content, resources): Promise<FilePath[]> { async emit(ctx, content, resources): Promise<FilePath[]> {
const fps: FilePath[] = [] const fps: FilePath[] = []