| | |
| | | |
| | | export const AliasRedirects: QuartzEmitterPlugin = () => ({ |
| | | name: "AliasRedirects", |
| | | getQuartzComponents() { |
| | | return [] |
| | | }, |
| | | async getDependencyGraph(ctx, content, _resources) { |
| | | const graph = new DepGraph<FilePath>() |
| | | |
| | |
| | | |
| | | return graph |
| | | }, |
| | | async emit(ctx, content, _resources): Promise<FilePath[]> { |
| | | const { argv } = ctx |
| | | const fps: FilePath[] = [] |
| | | |
| | | async *emit(ctx, content, _resources) { |
| | | for (const [_tree, file] of content) { |
| | | const ogSlug = simplifySlug(file.data.slug!) |
| | | |
| | | for (const slug of file.data.aliases ?? []) { |
| | | const redirUrl = resolveRelative(slug, file.data.slug!) |
| | | const fp = await write({ |
| | | yield write({ |
| | | ctx, |
| | | content: ` |
| | | <!DOCTYPE html> |
| | |
| | | slug, |
| | | ext: ".html", |
| | | }) |
| | | |
| | | fps.push(fp) |
| | | } |
| | | } |
| | | return fps |
| | | }, |
| | | }) |