From 614bd95ced2b7ad1632a0f36c35009426d6595b0 Mon Sep 17 00:00:00 2001 From: Pranav Kunjir Date: Wed, 28 Oct 2026 13:40:13 +0530 Subject: [PATCH 1/9] fix-edit-this-page-url Signed-off-by: Pranav Kunjir --- gatsby-node.js | 10 ++ package.json | 2 +- page-wrapper.js | 8 +- src/components/layout.js | 10 +- src/sections/General/Footer/index.js | 96 ++---------------- src/utils/edit-link.js | 50 ++++++++++ src/utils/edit-link.test.js | 144 +++++++++++++++++++++++++++ 7 files changed, 224 insertions(+), 96 deletions(-) create mode 100644 src/utils/edit-link.js create mode 100644 src/utils/edit-link.test.js diff --git a/gatsby-node.js b/gatsby-node.js index ecdf3bbf761e3b..a57b65fc0083b2 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -11,6 +11,16 @@ const slugify = require("./src/utils/slugify"); const { paginate } = require("gatsby-awesome-pagination"); const { createFilePath } = require("gatsby-source-filesystem"); const config = require("./gatsby-config"); +const { toEditUrl } = require("./src/utils/edit-link.js"); + +exports.onCreatePage = ({ page }) => { + const editUrl = toEditUrl(page.component, __dirname); + if (editUrl) { + page.context = { ...page.context, editUrl }; + } + return page; +}; + const { getExcludedCollections, isFullSiteBuild, diff --git a/package.json b/package.json index 2184bc58a44b96..cde486a372874f 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "lint": "eslint --fix .", "checklint": "eslint .", "check:contributing-versions": "node .github/scripts/check-contributing-versions.cjs", - "test:unit": "node --test src/utils/build-collections.test.js src/utils/page-path-guard.test.js", + "test:unit": "node --test src/utils/build-collections.test.js src/utils/page-path-guard.test.js src/utils/edit-link.test.js", "pretest": "eslint --ignore-path .gitignore .", "deploy": "gatsby build && gh-pages -d public -b master", "noIndex": "gatsby build && echo 'User-agent: *\nDisallow: /' > public/robots.txt", diff --git a/page-wrapper.js b/page-wrapper.js index 34dc1c2d21f9da..d255f7daebcff4 100644 --- a/page-wrapper.js +++ b/page-wrapper.js @@ -1,8 +1,6 @@ import React from "react"; import Layout from "./src/components/layout.js"; -export const wrapPageElement = ({ element }) => ( - - {element} - -); \ No newline at end of file +export const wrapPageElement = ({ element, props }) => ( + {element} +); diff --git a/src/components/layout.js b/src/components/layout.js index b7aa355292edcc..b0974ed2aa6f3e 100644 --- a/src/components/layout.js +++ b/src/components/layout.js @@ -16,23 +16,23 @@ import Footer from "../sections/General/Footer"; import { GlobalStyle } from "../sections/app.style"; import CookieConsent from "./CookieConsent"; -const Layout = ({ children }) => { - +const Layout = ({ children, pageContext }) => { return ( <> {/* */} - + {children} -