diff --git a/docs/gatsby-config.js b/docs/gatsby-config.js index 98cfc30ad..83e6d679c 100644 --- a/docs/gatsby-config.js +++ b/docs/gatsby-config.js @@ -48,6 +48,13 @@ module.exports = { path: `${__dirname}/../jacdac-spec/dist/services.json`, }, }, + { + resolve: `gatsby-source-filesystem`, + options: { + name: `serviceSources`, + path: `${__dirname}/../jacdac-spec/dist/services-sources.json`, + }, + }, { resolve: `gatsby-source-filesystem`, options: { diff --git a/docs/gatsby-node.js b/docs/gatsby-node.js index 96f7296fc..0c954175c 100644 --- a/docs/gatsby-node.js +++ b/docs/gatsby-node.js @@ -9,16 +9,22 @@ const { IgnorePlugin } = require('webpack') async function createServicePages(graphql, actions, reporter) { const { createPage, createRedirect } = actions const result = await graphql(` -{ - allServicesJson { - nodes { - name - shortName - shortId - classIdentifier + { + allServicesJson { + nodes { + name + shortName + shortId + classIdentifier + } + } + allServicesSourcesJson { + nodes { + source + classIdentifier + } } } -} `) if (result.errors) { @@ -34,16 +40,21 @@ async function createServicePages(graphql, actions, reporter) { // Instagram post. Since the scraped Instagram data // already includes an ID field, we just use that for // each page's path. - result.data.allServicesJson.nodes.forEach(node => { - const p = `/services/${node.shortId}/`; + result.data.allServicesJson.nodes.map((node) => { + const { classIdentifier, shortId } = node; + const p = `/services/${shortId}/`; const pplay = `${p}playground/` const ptest = `${p}test/` - const r = `/services/0x${node.classIdentifier.toString(16)}` + const r = `/services/0x${classIdentifier.toString(16)}` + + const source = result.data.allServicesSourcesJson.nodes.find(node => node.classIdentifier === classIdentifier).source + createPage({ path: p, component: slash(serviceTemplate), context: { - node + classIdentifier, + source, }, }) createPage({ diff --git a/docs/src/components/ServiceMarkdown.tsx b/docs/src/components/ServiceMarkdown.tsx index cc5b8d031..5c43f7216 100644 --- a/docs/src/components/ServiceMarkdown.tsx +++ b/docs/src/components/ServiceMarkdown.tsx @@ -3,16 +3,20 @@ import Markdown from "./ui/Markdown"; import ServiceSpecificationStatusAlert from "./ServiceSpecificationStatusAlert" import { Button, Link } from "gatsby-theme-material-ui"; import DeviceSpecificationList from "./DeviceSpecificationList"; +import { serviceSpecificationFromClassIdentifier } from "../../../src/jdom/spec"; export default function ServiceMarkdown(props: { - service: jdspec.ServiceSpec + classIdentifier: number, + source: string }) { - const { service: node } = props; - const { shortId, classIdentifier } = node; + const { classIdentifier, source } = props; + const service = serviceSpecificationFromClassIdentifier(classIdentifier) + const { shortId } = service; + return <> - - + +
diff --git a/docs/src/templates/service.mdx b/docs/src/templates/service.mdx index 93fc29f5a..c2c0830fd 100644 --- a/docs/src/templates/service.mdx +++ b/docs/src/templates/service.mdx @@ -1,5 +1,3 @@ -import { Link } from 'gatsby-theme-material-ui'; -import { serviceSpecificationFromClassIdentifier } from "../../../src/jdom/spec" import ServiceMarkdown from "../components/ServiceMarkdown" - + diff --git a/jacdac-spec b/jacdac-spec index e6c1cc174..cae9ac6b3 160000 --- a/jacdac-spec +++ b/jacdac-spec @@ -1 +1 @@ -Subproject commit e6c1cc174ba1283ef14ebf0ff99d4609654763de +Subproject commit cae9ac6b39cdaa2396ef25339da1a4b43f4e7d41