From 6947ab48a25e2fcead153045a77d99d1a85ce1af Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 8 Nov 2018 16:03:16 +0100 Subject: [PATCH] more internal link tests --- content/concepts/ecosystem.md | 2 ++ gatsby-config.js | 3 +- gatsby-node.js | 4 +-- .../gatsby-remark-relative-linker/index.js | 33 +++++++++++++++++++ .../package.json | 1 + 5 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 plugins/gatsby-remark-relative-linker/index.js create mode 100644 plugins/gatsby-remark-relative-linker/package.json diff --git a/content/concepts/ecosystem.md b/content/concepts/ecosystem.md index 821ba156..41cddd26 100644 --- a/content/concepts/ecosystem.md +++ b/content/concepts/ecosystem.md @@ -3,6 +3,8 @@ title: Ecosystem description: The Ocean Protocol network consists of various components. --- +[Architecture](./architecture/) + Learn about all of them here. - 💧 keeper. See also [Set Up a Keeper](/setup/keeper/) diff --git a/gatsby-config.js b/gatsby-config.js index dc430942..6d7e6f24 100755 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -42,7 +42,8 @@ module.exports = { }, 'gatsby-remark-smartypants', 'gatsby-remark-prismjs', - 'gatsby-remark-autolink-headers' + 'gatsby-remark-autolink-headers', + 'gatsby-remark-relative-linker' ] } }, diff --git a/gatsby-node.js b/gatsby-node.js index 20adfcfc..6827b7c2 100755 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -4,10 +4,10 @@ const { createFilePath } = require('gatsby-source-filesystem') exports.onCreateNode = ({ node, getNode, actions }) => { const { createNodeField } = actions - if (node.internal.type === `MarkdownRemark`) { + if (node.internal.type === 'MarkdownRemark') { const fileNode = getNode(node.parent) const parsedFilePath = path.parse(fileNode.relativePath) - const slug = createFilePath({ node, getNode }) + const slug = createFilePath({ node, getNode, basePath: 'content' }) const section = parsedFilePath.dir createNodeField({ diff --git a/plugins/gatsby-remark-relative-linker/index.js b/plugins/gatsby-remark-relative-linker/index.js new file mode 100644 index 00000000..e7e7fac8 --- /dev/null +++ b/plugins/gatsby-remark-relative-linker/index.js @@ -0,0 +1,33 @@ +// +// https://stackoverflow.com/a/48864225/733677 +// + +// const visit = require('unist-util-visit') + +// module.exports = ({ markdownAST }) => { +// visit(markdownAST, 'link', node => { +// if (node.url && node.url.endsWith('.md') && node.url.startsWith('./')) { +// node.url = node.url.replace( +// /(.*)\.(\w{2}).md(#.*)?$/gi, +// (match, base, hash) => { +// return `/` +// } +// ) +// } + +// if ( +// node.url && +// node.url.endsWith('.md') && +// node.url.startsWith('../') +// ) { +// node.url = node.url.replace( +// /(.*)\.(\w{2}).md(#.*)?$/gi, +// (match, base, hash) => { +// return `/` +// } +// ) +// } +// }) + +// return markdownAST +// } diff --git a/plugins/gatsby-remark-relative-linker/package.json b/plugins/gatsby-remark-relative-linker/package.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/plugins/gatsby-remark-relative-linker/package.json @@ -0,0 +1 @@ +{}