finish path refactoring, add sourcemap + better trace support

This commit is contained in:
Jacky Zhao 2023-07-15 23:02:12 -07:00
parent 906f91f8ee
commit 3ac6b42e16
36 changed files with 331 additions and 1170 deletions
quartz/plugins/emitters

View file

@ -1,4 +1,4 @@
import { CanonicalSlug, FilePath, ServerSlug, relativeToRoot } from "../../path"
import { CanonicalSlug, FilePath, ServerSlug, canonicalizeServer, resolveRelative } from "../../path"
import { QuartzEmitterPlugin } from "../types"
import path from 'path'
@ -11,7 +11,7 @@ export const AliasRedirects: QuartzEmitterPlugin = () => ({
const fps: FilePath[] = []
for (const [_tree, file] of content) {
const ogSlug = file.data.slug!
const ogSlug = canonicalizeServer(file.data.slug!)
const dir = path.relative(contentFolder, file.dirname ?? contentFolder)
let aliases: CanonicalSlug[] = []
@ -22,12 +22,10 @@ export const AliasRedirects: QuartzEmitterPlugin = () => ({
}
for (const alias of aliases) {
const slug = (alias.startsWith("/")
? alias
: path.posix.join(dir, alias)) as ServerSlug
const slug = path.posix.join(dir, alias) as ServerSlug
const fp = slug + ".html" as FilePath
const redirUrl = relativeToRoot(slug, ogSlug)
const redirUrl = resolveRelative(canonicalizeServer(slug), ogSlug)
await emit({
content: `
<!DOCTYPE html>