Skip to content

Commit

Permalink
fix: combine the permalink parts using url-join, fix #37 again
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Mar 31, 2019
1 parent 002e5ff commit 403fba1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/saber-plugin-query-posts/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path')
const urlJoin = require('url-join')

const ID = 'query-posts'

Expand Down Expand Up @@ -85,7 +85,7 @@ exports.apply = (api, options = {}) => {
const permalink =
index === 0
? page.attributes.permalink
: path.join(page.attributes.permalink, `page/${index + 1}`)
: urlJoin(page.attributes.permalink, `page/${index + 1}`)
const newPage = Object.assign({}, page, {
internal: Object.assign({}, page.internal, {
id:
Expand Down Expand Up @@ -147,7 +147,7 @@ exports.apply = (api, options = {}) => {
if (pageIndex === 0) {
return
}
return path.join(permalink, `page/${pageIndex}`)
return urlJoin(permalink, `page/${pageIndex}`)
}

function getTagName(tag, tagsMap) {
Expand Down
5 changes: 4 additions & 1 deletion packages/saber-plugin-query-posts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
"saber",
"saber-plugin"
],
"license": "MIT"
"license": "MIT",
"dependencies": {
"url-join": "^4.0.0"
}
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10412,6 +10412,11 @@ urix@^0.1.0:
resolved "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72"
integrity sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=

url-join@^4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/url-join/-/url-join-4.0.0.tgz#4d3340e807d3773bda9991f8305acdcc2a665d2a"
integrity sha1-TTNA6AfTdzvamZH4MFrNzCpmXSo=

url-loader@^1.1.2:
version "1.1.2"
resolved "https://registry.npmjs.org/url-loader/-/url-loader-1.1.2.tgz#b971d191b83af693c5e3fea4064be9e1f2d7f8d8"
Expand Down

0 comments on commit 403fba1

Please sign in to comment.