mirror of https://github.com/halo-dev/halo
feat: add post permalink type: YEAR (halo-dev/console#260)
parent
0844494bea
commit
72ad0937b5
|
@ -130,6 +130,10 @@ postApi.permalinkType = {
|
|||
type: 'DEFAULT',
|
||||
text: '默认'
|
||||
},
|
||||
YEAR: {
|
||||
type: 'YEAR',
|
||||
text: '年份型'
|
||||
},
|
||||
DATE: {
|
||||
type: 'DATE',
|
||||
text: '年月型'
|
||||
|
|
|
@ -22,6 +22,10 @@ Vue.filter('moment_post_date', function(dataStr, pattern = '/YYYY/MM/') {
|
|||
return dayjs(dataStr).format(pattern)
|
||||
})
|
||||
|
||||
Vue.filter('moment_post_year', function(dataStr, pattern = '/YYYY/') {
|
||||
return dayjs(dataStr).format(pattern)
|
||||
})
|
||||
|
||||
Vue.filter('moment_post_day', function(dataStr, pattern = '/YYYY/MM/DD/') {
|
||||
return dayjs(dataStr).format(pattern)
|
||||
})
|
||||
|
|
|
@ -425,6 +425,11 @@ export default {
|
|||
return `${blogUrl}/${archivesPrefix}/${
|
||||
this.selectedPost.slug ? this.selectedPost.slug : '{slug}'
|
||||
}${pathSuffix}`
|
||||
case 'YEAR':
|
||||
return `${blogUrl}${datetimeFormat(
|
||||
this.selectedPost.createTime ? this.selectedPost.createTime : new Date(),
|
||||
'/YYYY/'
|
||||
)}${this.selectedPost.slug ? this.selectedPost.slug : '{slug}'}${pathSuffix}`
|
||||
case 'DATE':
|
||||
return `${blogUrl}${datetimeFormat(
|
||||
this.selectedPost.createTime ? this.selectedPost.createTime : new Date(),
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<a-form-model-item label="文章固定链接类型:">
|
||||
<template slot="help">
|
||||
<span v-if="options.post_permalink_type === 'DEFAULT'">{{ options.blog_url }}/{{ options.archives_prefix }}/{slug}{{ options.path_suffix }}</span>
|
||||
<span v-else-if="options.post_permalink_type === 'YEAR'">{{ options.blog_url }}{{ new Date() | moment_post_year }}{slug}{{ options.path_suffix }}</span>
|
||||
<span v-else-if="options.post_permalink_type === 'DATE'">{{ options.blog_url }}{{ new Date() | moment_post_date }}{slug}{{ options.path_suffix }}</span>
|
||||
<span v-else-if="options.post_permalink_type === 'DAY'">{{ options.blog_url }}{{ new Date() | moment_post_day }}{slug}{{ options.path_suffix }}</span>
|
||||
<span v-else-if="options.post_permalink_type === 'ID'">{{ options.blog_url }}/?p={id}</span>
|
||||
|
|
Loading…
Reference in New Issue