mirror of
https://github.com/oceanprotocol/market.git
synced 2024-11-14 17:24:51 +01:00
42 lines
992 B
JavaScript
42 lines
992 B
JavaScript
const path = require('path')
|
|
const axios = require('axios')
|
|
// const { config } = require('./src/config/ocean')
|
|
|
|
exports.onCreateWebpackConfig = ({ actions }) => {
|
|
actions.setWebpackConfig({
|
|
node: {
|
|
// 'fs' fix for squid.js
|
|
fs: 'empty'
|
|
}
|
|
})
|
|
}
|
|
|
|
exports.createPages = async ({ actions, reporter }) => {
|
|
const { createPage } = actions
|
|
// Query for markdown nodes to use in creating pages.
|
|
const result = await axios(
|
|
`https://aquarius.marketplace.oceanprotocol.com/api/v1/aquarius/assets`
|
|
)
|
|
const assets = result.data.ids
|
|
|
|
// Handle errors
|
|
if (result.errors) {
|
|
reporter.panicOnBuild(`Error while querying Aquarius for all assets.`)
|
|
return
|
|
}
|
|
|
|
// Create pages for each DID
|
|
const assetDetailsTemplate = path.resolve(
|
|
`src/components/templates/AssetDetails/index.tsx`
|
|
)
|
|
assets.forEach((did) => {
|
|
const path = `/asset/${did}`
|
|
|
|
createPage({
|
|
path,
|
|
component: assetDetailsTemplate,
|
|
context: { did }
|
|
})
|
|
})
|
|
}
|