fix: remove index.html when using createContentLoader (#2693)

Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
pull/2708/head
烽宁 11 months ago committed by GitHub
parent 5d18fd8978
commit 6fc88a5cce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -43,7 +43,7 @@ function normalizeLink(
? link.replace(/\/$/, '') +
ensureStartingSlash(
path
.replace(/(^|\/)?index.md$/, '$1')
.replace(/(^|\/)index\.md$/, '$1')
.replace(/\.md$/, addExt ? '.html' : '')
)
: link

@ -19,7 +19,7 @@ export async function generateSitemap(siteConfig: SiteConfig) {
siteConfig.pages.map(async (page) => {
//
let url = siteConfig.rewrites.map[page] || page
url = url.replace(/(^|\/)?index.md$/, '$1')
url = url.replace(/(^|\/)index\.md$/, '$1')
url = url.replace(/\.md$/, siteConfig.cleanUrls ? '' : '.html')
const lastmod = siteConfig.lastUpdated && (await getGitTimestamp(page))

@ -141,10 +141,9 @@ export function createContentLoader<T = ContentData[]>(
)
const url =
'/' +
normalizePath(path.relative(config.srcDir, file)).replace(
/\.md$/,
config.cleanUrls ? '' : '.html'
)
normalizePath(path.relative(config.srcDir, file))
.replace(/(^|\/)index\.md$/, '$1')
.replace(/\.md$/, config.cleanUrls ? '' : '.html')
const html = render ? md.render(src) : undefined
const renderedExcerpt = renderExcerpt
? excerpt && md.render(excerpt)

@ -119,7 +119,7 @@ export async function localSearchPlugin(
let relFile = slash(path.relative(siteConfig.srcDir, file))
relFile = siteConfig.rewrites.map[relFile] || relFile
let id = slash(path.join(siteConfig.site.base, relFile))
id = id.replace(/\/index\.md$/, '/')
id = id.replace(/(^|\/)index\.md$/, '$1')
id = id.replace(/\.md$/, siteConfig.cleanUrls ? '' : '.html')
return id
}

Loading…
Cancel
Save