2018-11-18 23:52:57 +01:00
|
|
|
const { createMarkdownFields } = require('./gatsby/createMarkdownFields')
|
2019-10-31 00:51:53 +01:00
|
|
|
const { createExif } = require('./gatsby/createExif')
|
2018-10-14 02:25:24 +02:00
|
|
|
const {
|
|
|
|
generatePostPages,
|
|
|
|
generateTagPages,
|
2020-07-19 13:31:27 +02:00
|
|
|
generateRedirectPages,
|
|
|
|
generateArchivePages,
|
|
|
|
generatePhotosPages
|
2018-10-14 02:25:24 +02:00
|
|
|
} = require('./gatsby/createPages')
|
2019-04-13 22:52:58 +02:00
|
|
|
const { generateJsonFeed } = require('./gatsby/feeds')
|
2018-09-06 22:28:28 +02:00
|
|
|
|
2019-10-31 00:51:53 +01:00
|
|
|
exports.onCreateNode = ({ node, actions, getNode, createNodeId }) => {
|
2018-09-13 00:46:40 +02:00
|
|
|
// Markdown files
|
2018-07-17 23:33:55 +02:00
|
|
|
if (node.internal.type === 'MarkdownRemark') {
|
2019-10-31 00:51:53 +01:00
|
|
|
createMarkdownFields(node, actions, getNode)
|
2018-09-13 00:46:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Image files
|
|
|
|
if (node.internal.mediaType === 'image/jpeg') {
|
2019-10-31 00:51:53 +01:00
|
|
|
createExif(node, actions, createNodeId)
|
2018-09-12 21:03:35 +02:00
|
|
|
}
|
2018-09-09 21:20:19 +02:00
|
|
|
}
|
|
|
|
|
2020-07-19 13:31:27 +02:00
|
|
|
exports.createPages = async ({ graphql, actions, reporter }) => {
|
2018-09-24 23:50:48 +02:00
|
|
|
const { createPage, createRedirect } = actions
|
2018-07-17 23:33:55 +02:00
|
|
|
|
2019-01-04 18:51:03 +01:00
|
|
|
const result = await graphql(`
|
|
|
|
{
|
2020-07-19 13:31:27 +02:00
|
|
|
all: allMarkdownRemark(sort: { order: DESC, fields: [fields___date] }) {
|
2019-01-04 18:51:03 +01:00
|
|
|
edges {
|
2019-11-11 01:00:26 +01:00
|
|
|
next {
|
|
|
|
fields {
|
|
|
|
slug
|
|
|
|
}
|
|
|
|
frontmatter {
|
|
|
|
title
|
|
|
|
}
|
|
|
|
}
|
2019-01-04 18:51:03 +01:00
|
|
|
node {
|
|
|
|
fields {
|
|
|
|
slug
|
|
|
|
}
|
|
|
|
frontmatter {
|
|
|
|
tags
|
2018-07-17 23:33:55 +02:00
|
|
|
}
|
|
|
|
}
|
2019-11-11 01:00:26 +01:00
|
|
|
previous {
|
|
|
|
fields {
|
|
|
|
slug
|
|
|
|
}
|
|
|
|
frontmatter {
|
|
|
|
title
|
|
|
|
}
|
|
|
|
}
|
2018-07-17 23:33:55 +02:00
|
|
|
}
|
2019-01-04 18:51:03 +01:00
|
|
|
}
|
2019-11-06 20:44:33 +01:00
|
|
|
|
2021-02-28 04:50:05 +01:00
|
|
|
photos: allMarkdownRemark(filter: { fields: { type: { eq: "photo" } } }) {
|
2020-07-19 13:31:27 +02:00
|
|
|
edges {
|
|
|
|
node {
|
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-11 11:42:37 +02:00
|
|
|
archive: allMarkdownRemark(
|
2021-03-16 00:13:01 +01:00
|
|
|
filter: { fields: { type: { nin: "photo" } } }
|
2020-07-11 11:42:37 +02:00
|
|
|
) {
|
|
|
|
edges {
|
|
|
|
node {
|
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-06 20:44:33 +01:00
|
|
|
tags: allMarkdownRemark {
|
|
|
|
group(field: frontmatter___tags) {
|
|
|
|
tag: fieldValue
|
|
|
|
totalCount
|
|
|
|
}
|
|
|
|
}
|
2019-01-04 18:51:03 +01:00
|
|
|
}
|
|
|
|
`)
|
2018-07-17 23:33:55 +02:00
|
|
|
|
2020-07-19 13:31:27 +02:00
|
|
|
if (result.errors) {
|
|
|
|
reporter.panicOnBuild(`Error while running GraphQL query.`)
|
|
|
|
return
|
|
|
|
}
|
2018-07-19 00:22:06 +02:00
|
|
|
|
2020-07-19 13:31:27 +02:00
|
|
|
const all = result.data.all.edges
|
|
|
|
const photosLength = result.data.photos.edges.length
|
2020-07-11 11:42:37 +02:00
|
|
|
const archiveLength = result.data.archive.edges.length
|
2019-11-06 20:44:33 +01:00
|
|
|
const tags = result.data.tags.group
|
2018-07-19 23:04:41 +02:00
|
|
|
|
2020-07-19 13:31:27 +02:00
|
|
|
// Generate post pages
|
|
|
|
generatePostPages(createPage, all)
|
|
|
|
|
2021-02-28 22:14:36 +01:00
|
|
|
// Generate photos archive pages
|
2020-07-19 13:31:27 +02:00
|
|
|
generatePhotosPages(createPage, photosLength)
|
2018-07-19 23:04:41 +02:00
|
|
|
|
2019-04-13 22:52:58 +02:00
|
|
|
// Generate tag pages
|
2019-11-06 20:44:33 +01:00
|
|
|
generateTagPages(createPage, tags)
|
2018-09-24 23:50:48 +02:00
|
|
|
|
2021-03-16 00:13:01 +01:00
|
|
|
// Generate archive pages
|
|
|
|
generateArchivePages(createPage, archiveLength)
|
|
|
|
|
2019-04-13 22:52:58 +02:00
|
|
|
// Create manual redirects
|
2019-01-04 18:51:03 +01:00
|
|
|
generateRedirectPages(createRedirect)
|
2018-07-17 23:33:55 +02:00
|
|
|
}
|
2019-01-08 21:59:55 +01:00
|
|
|
|
2019-04-13 22:52:58 +02:00
|
|
|
exports.onPostBuild = async ({ graphql }) => {
|
|
|
|
// JSON Feed query
|
|
|
|
const result = await graphql(`
|
|
|
|
{
|
2020-07-11 10:29:42 +02:00
|
|
|
allMarkdownRemark(sort: { order: DESC, fields: [fields___date] }) {
|
2019-04-13 22:52:58 +02:00
|
|
|
edges {
|
|
|
|
node {
|
|
|
|
html
|
|
|
|
fields {
|
|
|
|
slug
|
|
|
|
date
|
|
|
|
}
|
|
|
|
excerpt
|
|
|
|
frontmatter {
|
|
|
|
title
|
|
|
|
tags
|
|
|
|
updated
|
|
|
|
image {
|
|
|
|
childImageSharp {
|
|
|
|
resize(width: 940, quality: 85) {
|
|
|
|
src
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
if (result.errors) throw result.errors
|
|
|
|
|
|
|
|
// Generate json feed
|
|
|
|
await generateJsonFeed(result.data.allMarkdownRemark.edges)
|
|
|
|
|
|
|
|
return Promise.resolve()
|
|
|
|
}
|
2022-05-08 14:49:18 +02:00
|
|
|
|
2022-09-17 15:58:59 +02:00
|
|
|
exports.onCreateWebpackConfig = ({ actions }) => {
|
2022-05-08 14:49:18 +02:00
|
|
|
actions.setWebpackConfig({
|
|
|
|
resolve: {
|
|
|
|
fallback: {
|
|
|
|
util: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|