mirror of
https://github.com/pengzhanbo/vuepress-theme-plume.git
synced 2026-04-23 10:58:13 +08:00
perf(plugin-blog-data): 排除文章摘要中的标题部分
This commit is contained in:
parent
5b4da6f04b
commit
aa70bf9809
@ -21,6 +21,8 @@ if (import.meta.hot) {
|
||||
}
|
||||
`
|
||||
|
||||
const headingRe = /<h(\d*).*?>.*?<\/h\1>/gi
|
||||
|
||||
function getTimestamp(time: Date): number {
|
||||
return new Date(time).getTime()
|
||||
}
|
||||
@ -69,7 +71,10 @@ export async function preparedBlogData(app: App, pageFilter: (id: string) => boo
|
||||
|
||||
if (options.excerpt && page.contentRendered.includes(EXCERPT_SPLIT)) {
|
||||
const contents = page.contentRendered.split(EXCERPT_SPLIT)
|
||||
data.excerpt = contents[0]
|
||||
let excerpt = contents[0]
|
||||
// 删除摘要中的标题
|
||||
excerpt = excerpt.replace(headingRe, '')
|
||||
data.excerpt = excerpt
|
||||
}
|
||||
|
||||
return data as BlogPostDataItem
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user