From 88896b9d9b90c3fce7aa0708497589fb36ac92fb Mon Sep 17 00:00:00 2001 From: Tim Glaser Date: Thu, 18 Jun 2020 11:21:40 -0700 Subject: [PATCH] feat: Populate edit url --- gatsby-node.js | 8 +++++++- src/components/Footer.js | 19 +++++++++++++------ src/components/Layout.js | 4 +++- src/pages/index.js | 2 +- src/templates/GuideTemplate.js | 5 +++-- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/gatsby-node.js b/gatsby-node.js index 9eb81e796..406717cb2 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -8,6 +8,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => { allMdx(limit: 1000) { edges { node { + fileAbsolutePath frontmatter { path template @@ -28,7 +29,12 @@ exports.createPages = async ({ actions, graphql, reporter }) => { createPage({ path: node.frontmatter.path, component: path.resolve(`src/templates/${node.frontmatter.template}.js`), - context: {}, // additional data can be passed via context + context: { + fileRelativePath: node.fileAbsolutePath.replace( + `${process.cwd()}/`, + '' + ), + }, }); }); }; diff --git a/src/components/Footer.js b/src/components/Footer.js index 55ff26683..01af3d44d 100644 --- a/src/components/Footer.js +++ b/src/components/Footer.js @@ -7,7 +7,9 @@ import FeatherIcon from './FeatherIcon'; import Logo from './Logo'; import PropTypes from 'prop-types'; -const Footer = ({ className }) => ( +const githubBaseUrl = 'https://github.com/newrelic/developer-website'; + +const Footer = ({ className, fileRelativePath }) => (