markdownFileToPagePath #
Markdown 文件的页面路径:它的源路径在应用 rewrites 之后的结果。例如 packages/a/src/intro.md 配上规则 'packages/:pkg/src/:page*': ':pkg/:page*',得到 /a/intro.md。没有 rewrites 时就是源路径。页面的路由和它的相对链接都从这里算起。
用法 #
TypeScript
import { markdownFileToPagePath } from 'kawapress/generator'
const path = markdownFileToPagePath('/site/a.md', '/site')
参数
filestring
Markdown 文件的绝对路径。
sourceRootstring
源码目录的绝对路径,也就是解析后的 srcDir。
rewrites可选PageRewrites
站点配置里的 rewrites。
返回值 页面路径,例如 /a/intro.md。
完整类型签名
TypeScript
function markdownFileToPagePath(file: string, sourceRoot: string, rewrites?: PageRewrites): string

评论