mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
url前缀 %category% 支持映射
This commit is contained in:
@@ -224,6 +224,8 @@ function generateCustomizeSlug(postProperties, NOTION_CONFIG) {
|
||||
NOTION_CONFIG
|
||||
).split('/')
|
||||
|
||||
const POST_URL_PREFIX_MAPPING_CATEGORY = siteConfig('POST_URL_PREFIX_MAPPING_CATEGORY',{},NOTION_CONFIG)
|
||||
|
||||
allSlugPatterns.forEach((pattern, idx) => {
|
||||
if (pattern === '%year%' && postProperties?.publishDay) {
|
||||
const formatPostCreatedDate = new Date(postProperties?.publishDay)
|
||||
@@ -240,7 +242,12 @@ function generateCustomizeSlug(postProperties, NOTION_CONFIG) {
|
||||
} else if (pattern === '%slug%') {
|
||||
fullPrefix += postProperties.slug ?? postProperties.id
|
||||
} else if (pattern === '%category%' && postProperties?.category) {
|
||||
fullPrefix += postProperties.category
|
||||
let categoryPrefix = postProperties.category
|
||||
// 允许映射分类名,通常用来将中文分类映射成英文,美化url.
|
||||
if(POST_URL_PREFIX_MAPPING_CATEGORY[postProperties?.category]){
|
||||
categoryPrefix = POST_URL_PREFIX_MAPPING_CATEGORY[postProperties?.category]
|
||||
}
|
||||
fullPrefix += categoryPrefix
|
||||
} else if (!pattern.includes('%')) {
|
||||
fullPrefix += pattern
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user