1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-06-30 22:01:44 +02: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/`
}
},
'gatsby-source-ocean',
{
resolve: 'gatsby-source-ocean',
options: {
aquariusUri: 'https://aquarius.marketplace.oceanprotocol.com'
}
},
{
resolve: 'gatsby-plugin-sharp',
options: {

View File

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

View File

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

View File

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