使用 中文 tag 之后的 $pagination.pages 返回不太正确
yuicer opened this issue · comments
yuicer commented
参照 vuepress-plugin-blog/examples/blog 下面的配置如下
'@vuepress/blog',
{
directories: [
{
id: 'post',
dirname: '_post',
path: '/'
}
],
frontmatters: [
{
id: 'tag',
keys: ['tag'],
path: '/tag/',
layout: 'Tag'
}
]
}
当我使用中文 tag ,当我在 url my-host/tag/中文/
的时候,$pagination.pages 返回的文章数组并不符合我当前的 tag,似乎没什么规律。orz。然而这时 $tags 和 $currentTag 中的数据返回的是正确的。
我又测试了英文 tag,这时候 $pagination.pages 是正确的,猜想错误返回的原因是否和 tag 是中文有关?
ULIVZ commented
看起来是 encode 的问题, 欢迎 PR!
yuicer commented
看起来像是 resolvePaginationConfig 的参数有问题。不是很确定。。。下面的 getFrontmatterClassifierPageFilter
的第二个参数取到的值是错的。看这个意外的花时间。。。。 @ulivz 大大能给修下吗
function resolvePaginationConfig(
classifierType,
pagination = {},
indexPath,
pid,
id,
ctx,
keys = ['']
) {
return Object.assign(
{},
{
lengthPerPage: 10,
layout: ctx.getLayout(Classifier_1.DefaultLayoutEnum.DirectoryPagination),
getPaginationPageUrl(index) {
if (index === 0) {
return indexPath
}
return `${indexPath}page/${index + 1}/`
},
filter:
classifierType === Classifier_1.ClassifierTypeEnum.Directory
? getIdentityFilter(pid, id)
: getFrontmatterClassifierPageFilter(keys, id),
sorter: (prev, next) => {
const prevTime = new Date(prev.frontmatter.date).getTime()
const nextTime = new Date(next.frontmatter.date).getTime()
return prevTime - nextTime > 0 ? -1 : 1
}
},
pagination
)
}
Billy Chin commented
Is this still an issue?