Skip to content

Commit

Permalink
add process.env.PATH_PREFIX
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleguido committed Mar 8, 2024
1 parent 8b8efa9 commit 9e498f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ const debug = require('debug')('datalab:gatsby-node')
const fs = require('fs')

debug('gatsby-node.js')
const NotebooksJsonFilepath = './static/data/notebooks.json'
const AuthorsJsonFilepath = './static/data/authors.json'
const CollectionsJsonFilepath = './static/data/collections.json'
const NotebooksJsonFilepath = __dirname + '/static/data/notebooks.json'
const AuthorsJsonFilepath = __dirname + '/static/data/authors.json'
const CollectionsJsonFilepath = __dirname + '/static/data/collections.json'

exports.createPages = async function ({ actions, graphql }) {
const authorsMap = {}
const notebooksMap = {}
const collectionsMap = {}
if (!fs.existsSync('./static/data/notebooks')) {
fs.mkdirSync('./static/data/notebooks')
if (!fs.existsSync(__dirname + '/static/data/notebooks')) {
fs.mkdirSync(__dirname + '/static/data/notebooks')
}

const { data: authors } = await graphql(`
Expand Down Expand Up @@ -90,7 +90,7 @@ exports.createPages = async function ({ actions, graphql }) {
})

fs.writeFileSync(
`./static/data/notebooks/${node.name}.json`,
`${__dirname}/static/data/notebooks/${node.name}.json`,
JSON.stringify(
{
...notebooksMap[node.name],
Expand Down
8 changes: 4 additions & 4 deletions src/components/PrefetchData.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ const PrefetchData = () => {
queryFn: () =>
Promise.all(
[
'/data/authors.json',
'/data/notebooks.json',
'/data/collections.json',
'data/authors.json',
'data/notebooks.json',
'data/collections.json',
].map((url) =>
axios.get(url).then((res) => {
axios.get((process.env.PATH_PREFIX || '/') + url).then((res) => {
console.info(`[PrefetchData] ${url}`, res.data)
return res.data
})
Expand Down

0 comments on commit 9e498f9

Please sign in to comment.