I have a bunch of Directories that I am using as gatsby nodes and generating pages from these Directories like:
exports.createPages = async ({ graphql, actions }) => {
const { createPage } = actions
const result = await graphql(`
query DosboxQuery {
allDirectory(filter: {sourceInstanceName: {eq: "dosbox"} name: {ne: "dosbox"}}) {
edges {
node {
name
dir
modifiedTime
children {
__typename ... on File{
name
relativePath
}
}
}
}
}
`)
result.data.allDirectory.edges.forEach(({ node }) => {
console.log("directory node", node);
createPage({
path: `/${node.name}/`,
component: path.resolve(`./src/templates/game-page.js`),
context: {
slug: `/${node.name}/`,
},
})
})
console.log(JSON.stringify(result, null, 4))
}
I would like to generate zip archives of these Directories that users could download from the pages. I don't want to store or commit the zip archives because the content of the directories can change so I want to create the zip archives at gatsby build time. I can probably use a npm module like archiver to create the zip archives.
I'm not sure how to integrate the zip archives into the gatsby infrastructure. I could update onCreateNode or createPages to create the zips. should I write the zips to the public folder? can I store the zips as buffers on the gatsby node?