Skip to content

Commit

Permalink
🔄 synced local 'quartz/' with remote 'quartz/'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mara-Li committed Feb 16, 2024
1 parent b3d3735 commit a109a2d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
27 changes: 24 additions & 3 deletions quartz/plugins/emitters/aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,30 @@ export const AliasRedirects: QuartzEmitterPlugin = () => ({
getQuartzComponents() {
return []
},
async getDependencyGraph(_ctx, _content, _resources) {
// TODO implement
return new DepGraph<FilePath>()
async getDependencyGraph(ctx, content, _resources) {
const graph = new DepGraph<FilePath>()

const { argv } = ctx
for (const [_tree, file] of content) {
const dir = path.posix.relative(argv.directory, path.dirname(file.data.filePath!))
const aliases = file.data.frontmatter?.aliases ?? []
const slugs = aliases.map((alias) => path.posix.join(dir, alias) as FullSlug)
const permalink = file.data.frontmatter?.permalink
if (typeof permalink === "string") {
slugs.push(permalink as FullSlug)
}

for (let slug of slugs) {
// fix any slugs that have trailing slash
if (slug.endsWith("/")) {
slug = joinSegments(slug, "index") as FullSlug
}

graph.addEdge(file.data.filePath!, joinSegments(argv.output, slug + ".html") as FilePath)
}
}

return graph
},
async emit(ctx, content, _resources): Promise<FilePath[]> {
const { argv } = ctx
Expand Down
19 changes: 14 additions & 5 deletions quartz/plugins/emitters/folderPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,21 @@ export const FolderPage: QuartzEmitterPlugin<Partial<FullPageLayout>> = (userOpt
getQuartzComponents() {
return [Head, Header, Body, ...header, ...beforeBody, pageBody, ...left, ...right, Footer]
},
async getDependencyGraph(_ctx, _content, _resources) {
async getDependencyGraph(_ctx, content, _resources) {
// Example graph:
// nested/file.md --> nested/file.html
// \-------> nested/index.html
// TODO implement
return new DepGraph<FilePath>()
// nested/file.md --> nested/index.html
// nested/file2.md ------^
const graph = 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[]> {
const fps: FilePath[] = []
Expand Down

0 comments on commit a109a2d

Please sign in to comment.