MCPcopy
hub / github.com/datawhalechina/easy-vibe / mdPathToUrl

Function mdPathToUrl

scripts/generate-sitemap.mjs:78–91  ·  view source on GitHub ↗
(mdPath, locale)

Source from the content-addressed store, hash-verified

76
77// 将 markdown 路径转换为 URL 路径
78function mdPathToUrl(mdPath, locale) {
79 // 移除 .md 扩展名
80 let urlPath = mdPath.replace(/\.md$/, '')
81
82 // 如果是 index.md,只保留目录
83 if (urlPath.endsWith('/index')) {
84 urlPath = urlPath.slice(0, -6)
85 } else if (urlPath === 'index') {
86 urlPath = ''
87 }
88
89 // 构建完整 URL
90 return `${siteUrl}/${locale}/${urlPath}${urlPath ? '/' : ''}`
91}
92
93function getGitLastModified(filePath) {
94 try {

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected