mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-04 01:05:58 +02:00
feat: persist layout state across pages
This commit is contained in:
@@ -6,6 +6,9 @@ const fs = require("fs")
|
||||
|
||||
const requiredArticleFrontmatter = ["authors", "date"]
|
||||
|
||||
const LAYOUT_RESOURCES = "resources"
|
||||
const LAYOUT_REGULAR = "regular"
|
||||
|
||||
let users = []
|
||||
try {
|
||||
users = JSON.parse(fs.readFileSync("./users.json", "utf-8"))
|
||||
@@ -51,6 +54,7 @@ const createResources = async ({ createPage, graphql }) => {
|
||||
component: languageResources,
|
||||
context: {
|
||||
file: node.relativePath,
|
||||
layout: LAYOUT_RESOURCES,
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -84,6 +88,15 @@ exports.onCreateNode = async ({ node, getNode, actions }) => {
|
||||
}
|
||||
}
|
||||
|
||||
exports.onCreatePage = ({ page, actions }) => {
|
||||
const { createPage } = actions
|
||||
|
||||
page.context.layout = page.path.match(/resources/)
|
||||
? LAYOUT_RESOURCES
|
||||
: LAYOUT_REGULAR
|
||||
createPage(page)
|
||||
}
|
||||
|
||||
exports.createPages = ({ actions, graphql }) => {
|
||||
const { createPage } = actions
|
||||
return createResources({ createPage, graphql })
|
||||
|
||||
Reference in New Issue
Block a user