1
1
mirror of https://github.com/jxnblk/mdx-deck.git synced 2024-09-17 09:57:23 +03:00

Merge pull request #406 from jxnblk/fix-routing

Adjust slug in single deck mode
This commit is contained in:
Brent Jackson 2019-07-19 10:20:57 -04:00 committed by GitHub
commit 8f45f6a540
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -101,14 +101,15 @@ exports.createPages = async ({ graphql, actions, reporter }) => {
// single deck mode
if (decks.length === 1) {
const [deck] = decks
const matchPath = path.join(basePath, '*')
const matchPath = [basePath, '*'].join('/')
const slug = basePath === '/' ? '' : basePath
createPage({
path: basePath,
matchPath,
component: DeckTemplate,
context: {
...deck.node,
slug: basePath,
slug,
},
})
return
@ -116,7 +117,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => {
decks.forEach(({ node }, index) => {
const { slug } = node
const matchPath = path.join(slug, '*')
const matchPath = [slug, '*'].join('/')
createPage({
path: slug,