提交 93f169a1 编写于 作者: U ULIVZ

fix($pagination): do not need to withBase & do not generate root html

上级 e2b6be83
...@@ -10,14 +10,6 @@ function getIntervallers (max, interval) { ...@@ -10,14 +10,6 @@ function getIntervallers (max, interval) {
}) })
} }
function withBase (base, path) {
if (path.charAt(0) === '/') {
return base + path.slice(1)
} else {
return path
}
}
module.exports = (options, ctx) => ({ module.exports = (options, ctx) => ({
enhanceAppFiles: [ enhanceAppFiles: [
path.resolve(__dirname, 'enhanceApp.js') path.resolve(__dirname, 'enhanceApp.js')
...@@ -32,7 +24,7 @@ module.exports = (options, ctx) => ({ ...@@ -32,7 +24,7 @@ module.exports = (options, ctx) => ({
return prevTime - nextTime > 0 ? -1 : 1 return prevTime - nextTime > 0 ? -1 : 1
}) })
const { pages, base } = ctx const { pages } = ctx
const posts = pages.filter(postsFilter) const posts = pages.filter(postsFilter)
const { const {
perPagePosts = 10, perPagePosts = 10,
...@@ -41,12 +33,11 @@ module.exports = (options, ctx) => ({ ...@@ -41,12 +33,11 @@ module.exports = (options, ctx) => ({
layout = 'Layout' layout = 'Layout'
} = options } = options
const normalizedfirstPagePath = withBase(base, firstPagePath)
const intervallers = getIntervallers(posts.length, perPagePosts) const intervallers = getIntervallers(posts.length, perPagePosts)
const pagination = { const pagination = {
paginationPages: intervallers.map((interval, index) => { paginationPages: intervallers.map((interval, index) => {
const path = index === 0 const path = index === 0
? normalizedfirstPagePath ? firstPagePath
: `/${paginationDir}/${index + 1}/` : `/${paginationDir}/${index + 1}/`
return { path, interval } return { path, interval }
}), }),
...@@ -56,6 +47,9 @@ module.exports = (options, ctx) => ({ ...@@ -56,6 +47,9 @@ module.exports = (options, ctx) => ({
ctx.pagination = pagination ctx.pagination = pagination
pagination.paginationPages.forEach(({ path }) => { pagination.paginationPages.forEach(({ path }) => {
if (path === '/') {
return
}
ctx.addPage({ ctx.addPage({
permalink: path, permalink: path,
frontmatter: { layout } frontmatter: { layout }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册