1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

gatsby-source-ocean: add plugin options, new node type name

This commit is contained in:
Matthias Kretschmann 2020-07-07 09:55:20 +02:00
parent 85b76a727b
commit 7cee5eee21
Signed by: m
GPG Key ID: 606EEEF3C479A91F
4 changed files with 20 additions and 18 deletions

View File

@ -28,7 +28,12 @@ module.exports = {
path: `${__dirname}/node_modules/@oceanprotocol/art/` path: `${__dirname}/node_modules/@oceanprotocol/art/`
} }
}, },
'gatsby-source-ocean', {
resolve: 'gatsby-source-ocean',
options: {
aquariusUri: 'https://aquarius.marketplace.oceanprotocol.com'
}
},
{ {
resolve: 'gatsby-plugin-sharp', resolve: 'gatsby-plugin-sharp',
options: { options: {

View File

@ -20,7 +20,7 @@ exports.createPages = async ({ graphql, actions }) => {
const result = await graphql(` const result = await graphql(`
query { query {
allAsset { allOceanAsset {
edges { edges {
node { node {
did did
@ -53,7 +53,7 @@ exports.createPages = async ({ graphql, actions }) => {
throw result.errors throw result.errors
} }
await result.data.allAsset.edges.forEach(({ node }) => { await result.data.allOceanAsset.edges.forEach(({ node }) => {
const path = `/asset/${node.did}` const path = `/asset/${node.did}`
createPage({ createPage({

View File

@ -1,22 +1,20 @@
const axios = require('axios') const axios = require('axios')
exports.sourceNodes = async ({ exports.sourceNodes = async (
actions, { actions, createNodeId, createContentDigest },
createNodeId, pluginOptions
createContentDigest ) => {
}) => {
const { createNode } = actions const { createNode } = actions
const { aquariusUri } = pluginOptions
// Query for all assets to use in creating pages. // Query for all assets to use in creating pages.
const result = await axios( const result = await axios(`${aquariusUri}/api/v1/aquarius/assets`)
`https://aquarius.marketplace.oceanprotocol.com/api/v1/aquarius/assets`
)
for (let i = 0; i < result.data.ids.length; i++) { for (let i = 0; i < result.data.ids.length; i++) {
const did = result.data.ids[i] const did = result.data.ids[i]
const metadataResult = await axios( const metadataResult = await axios(
`https://aquarius.marketplace.oceanprotocol.com/api/v1/aquarius/assets/metadata/${did}` `${aquariusUri}/api/v1/aquarius/assets/metadata/${did}`
) )
const metadata = { const metadata = {
@ -29,10 +27,9 @@ exports.sourceNodes = async ({
parent: null, parent: null,
children: [], children: [],
internal: { internal: {
type: 'Asset', type: 'OceanAsset',
mediaType: 'application/json', contentDigest: createContentDigest(metadata),
content: JSON.stringify(metadata), description: `All data sets queried from ${pluginOptions.aquariusUri}`
contentDigest: createContentDigest(metadata)
} }
} }

View File

@ -14,8 +14,8 @@ export default function AssetDetailsTemplate(props: PageProps): ReactElement {
} }
export const templateQuery = graphql` export const templateQuery = graphql`
query AssetByDid($did: String!) { query OceanAssetByDid($did: String!) {
asset(did: { eq: $did }) { oceanAsset(did: { eq: $did }) {
did did
main { main {
type type