diff --git a/gatsby-node.js b/gatsby-node.js index 04c8089..5dfdbc9 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -80,12 +80,20 @@ exports.createPages = async ({ graphql, actions }) => { pathname sourceInstanceName } + parent { + ... on File { + gitRemote { + webLink + } + } + } } } } } `); result.data.allMarkdownRemark.edges.forEach(({ node }) => { + const sourceLink = node.parent.gitRemote ? node.parent.gitRemote.webLink : null; createPage({ path: node.fields.pathname, component: path.resolve(`./src/templates/docs-page.js`), @@ -94,6 +102,7 @@ exports.createPages = async ({ graphql, actions }) => { // in page queries as GraphQL variables. pathname: node.fields.pathname, sourceInstanceName: node.fields.sourceInstanceName, + sourceLink, }, }); }); diff --git a/src/components/table-of-contents.js b/src/components/table-of-contents.js index 79364d5..3cd91b5 100644 --- a/src/components/table-of-contents.js +++ b/src/components/table-of-contents.js @@ -36,11 +36,16 @@ const useStyles = makeStyles(theme => ({ export default function TableOfContents(props) { const classes = useStyles(); - const { __html, headings, title = 'Table of contents' } = props; + const { __html, headings, source, title = 'Table of contents' } = props; const [tocRef, setActiveHeading] = useActiveHeading(headings, classes.active); return (<> +

+ + {source.sourceInstanceName} source + +

{title} depth === 1)?.value; const toc = { + source: { + sourceInstanceName, + sourceLink, + }, title, __html: tocHtml, headings: post.headings