Skip to main content

Page Metadata

3 min readStableBeginner

Under every page OwnDocs renders one small row: the last-updated date pulled from git log, the people who have touched the file, and an "Edit on GitHub" button. Scroll to the bottom of this page to see the live example. What follows covers the two git commands behind the row, the edit URL, and what happens when git has nothing to report.

Quick Start

Nothing to author and nothing to switch on. At build time OwnDocs runs two git commands against the page's own MDX file, keeps the first five unique authors, and renders the row.

Last updated

Author date of the newest commit that touched this file, printed as Aug 16, 2026 inside a <time> element.

Contributors

Up to five names, newest commit first, deduplicated by name and by email.

what runs at build time
Bash
git log -1 --format=%aI -- content/features/platform/page-metadata.mdx
git log --format='%an|%ae' -- content/features/platform/page-metadata.mdx

The first command feeds lastUpdatedIso, the second feeds contributors. When both come back empty and no edit URL is configured, the whole section returns null: no empty box, no placeholder text.

Adding Options

Point NEXT_PUBLIC_REPO_URL at the repository and the "Edit on GitHub" button appears on the right side of the same row.

.env.local
Bash
NEXT_PUBLIC_REPO_URL=https://github.com/your-org/your-repo

That produces https://github.com/your-org/your-repo/edit/main/content/features/platform/page-metadata.mdx. The path is the file's location relative to the project root, and the link opens in a new tab with rel="noopener noreferrer".

Advanced

Docs that live on a release branch need the branch name too, and the URL builder is more forgiving than it looks.

.env.local
Bash
NEXT_PUBLIC_REPO_URL=https://github.com/your-org/your-repo.git/
NEXT_PUBLIC_REPO_BRANCH=develop

getEditUrl cleans up both extra characters. It strips a trailing .git and a trailing slash from the repo URL and any leading slashes from the file path, then joins them as <repo>/edit/<branch>/<path>. The result is the same tidy .../edit/develop/content/features/platform/page-metadata.mdx.

getGitMeta handles three failure modes without raising an error:

  • No git binary on the build machine: the ENOENT case returns status unavailable with the error message kept on errorReason, and the footer renders nothing.
  • A file with no commit history, such as a page added but not yet committed: status no-history, and the row still renders if an edit URL is set.
  • A shallow clone (git clone --depth=1): git log sees one commit, so the contributor list shrinks to whoever made it. Turn on a full clone in the build platform's settings when the history matters.

React's cache() wraps getGitMeta, so the two commands run once per file per render pass no matter how many times the page asks for them.

The URL shape is GitHub's. GitLab uses /-/edit/, and Bitbucket uses /src/<branch>/<path>?mode=edit, so those hosts need an adjusted getEditUrl in lib/git-meta.ts.

Options

NEXT_PUBLIC_REPO_URLenv

Repository URL. Setting it enables the edit link; leaving it unset hides the button. getEditUrl trims a trailing .git or /.

NEXT_PUBLIC_REPO_BRANCHenvDefault: main

Branch segment in the edit URL.

lastUpdatedIsostring | nullrequired

ISO 8601 author date of the last commit. Rendered through toLocaleDateString('en-US', ...) as Aug 16, 2026, inside a <time> element carrying the raw ISO value in dateTime. An unparseable value prints as-is instead of throwing.

contributorsGitContributor[]required

Objects of { name, email }. The row renders only name; the email feeds deduplication and never reaches the page.

editUrlstring

Optional. Rendered as the "Edit on GitHub" button with an external-link icon. Omitted when NEXT_PUBLIC_REPO_URL is unset.

MAX_CONTRIBUTORSnumberDefault: 5

Hard cap on names, applied after deduplication. A module constant in lib/git-meta.ts, not a prop.

status'ok' | 'no-history' | 'unavailable'

Field on the GitMeta object returned by getGitMeta. Useful in a custom renderer that has to tell "this repo has no history" apart from "git could not run".

aria-labelstringDefault: Page metadata

Label on the wrapping <section> so screen readers announce the row as its own landmark.

Was this page helpful?

© 2026 DevOps. All rights reserved.