plugin integration round 2
This commit is contained in:
parent
a757521313
commit
ad6ce0d73f
29 changed files with 3863 additions and 100 deletions
19
quartz/path.ts
Normal file
19
quartz/path.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import path from 'path'
|
||||
|
||||
// Replaces all whitespace with dashes and URI encodes the rest
|
||||
export function pathToSlug(fp: string): string {
|
||||
const { dir, name } = path.parse(fp)
|
||||
let slug = path.join('/', dir, name)
|
||||
slug = slug.replace(/\s/g, '-')
|
||||
return slug
|
||||
}
|
||||
|
||||
// resolve /a/b/c to ../../
|
||||
export function resolveToRoot(slug: string): string {
|
||||
let fp = slug
|
||||
if (fp.endsWith("/index")) {
|
||||
fp = fp.slice(0, -"/index".length)
|
||||
}
|
||||
|
||||
return "./" + path.relative(fp, path.posix.sep)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue