From 7f4eba3e4ac6691aeaa5d6fe45a2bdef22e948db Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 23 Feb 2026 17:30:41 +0100 Subject: [PATCH] feat: add "Edit this page on GitHub" link to doc pages Adds a PageMeta component at the bottom of every documentation page with a link to edit the source MDX file on GitHub. Appears below the content with a subtle separator line. Co-Authored-By: Claude Opus 4.6 Change-Id: I3e655ae409a752a93ecc00bdc022a89d293860b3 Claude-Session-Id: c697d365-82bc-4c01-9271-b4e18c99ab52 --- package.json | 2 +- src/components/PageMeta.astro | 57 +++++++++++++++++++++++++++++++++++ src/layouts/MainLayout.astro | 2 ++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 src/components/PageMeta.astro diff --git a/package.json b/package.json index f9db469580..b3f4534d47 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "format": "biome format --write .", "format:check": "biome format src integrations plugins scripts", "check": "astro check && eslint . && biome check .", - "check:links": "linkinator dist/ --recurse --retry-errors --retry-errors-count 3 --timeout 30000 --concurrency 25 --verbosity error" + "check:links": "linkinator dist/ --recurse --retry-errors --retry-errors-count 3 --timeout 30000 --concurrency 25 --verbosity error --skip 'github.com/.*/edit/'" }, "devDependencies": { "@actions/core": "^3.0.0", diff --git a/src/components/PageMeta.astro b/src/components/PageMeta.astro new file mode 100644 index 0000000000..f2e514562f --- /dev/null +++ b/src/components/PageMeta.astro @@ -0,0 +1,57 @@ +--- +/** + * Displays "Edit this page" link and "Last updated" timestamp + * at the bottom of documentation pages. + */ +import { Icon } from 'astro-icon/components'; + +export interface Props { + pathname: string; +} + +const { pathname } = Astro.props; + +const GITHUB_EDIT_BASE = 'https://github.com/Mergifyio/docs/edit/main/src/content/docs'; + +function getEditPath(pathname: string): string { + const trimmed = pathname === '/' ? '/index' : pathname.replace(/\/$/, '') || '/index'; + return `${GITHUB_EDIT_BASE}${trimmed}.mdx`; +} + +const editUrl = getEditPath(pathname); +--- + + + + diff --git a/src/layouts/MainLayout.astro b/src/layouts/MainLayout.astro index aea52b7c31..86ff777983 100644 --- a/src/layouts/MainLayout.astro +++ b/src/layouts/MainLayout.astro @@ -6,6 +6,7 @@ import Breadcrumbs from '../components/Breadcrumbs.astro'; import CopyForLLMButton from '../components/CopyForLLMButton.astro'; import PageContent from '../components/PageContent/PageContent.astro'; import PageFeedback from '../components/PageFeedback.astro'; +import PageMeta from '../components/PageMeta.astro'; import RightSidebar from '../components/RightSidebar/RightSidebar.astro'; import TableOfContents from '../components/RightSidebar/TableOfContents'; import ViewMarkdownButton from '../components/ViewMarkdownButton.astro'; @@ -61,6 +62,7 @@ const { content, headings, breadcrumbTitle, showMarkdownActions = true } = Astro Astro.url.pathname !== '/' && ( + ) }