mirror of https://github.com/theNewDynamic/gohugo-theme-ananke.git

Patrick Kollitsch
11 hours ago 688f3584ad4d3625cd001855c1f01448316252ba
refs
author Patrick Kollitsch <83281+davidsneighbour@users.noreply.github.com>
Sunday, June 7, 2026 11:40 +0200
committer GitHub <noreply@github.com>
Sunday, June 7, 2026 11:40 +0200
commit688f3584ad4d3625cd001855c1f01448316252ba
tree d5d63fa248b2d10353953a60177a645b58f5cbe8 tree | zip | gz
parent 45143b564b99709c2c23664de0bbcb7b1d30b17e view | diff
feat: add edit-page shortcode for GitHub edit links (#1028)

## Summary

Adds a reusable **"Improve this page on GitHub"** edit link, the
affordance documentation sites commonly place at the foot of a page.

- **`layouts/_partials/edit-page.html`** — single source of truth.
Builds the GitHub edit URL
`{repo_url}/edit/{branch}/{content_dir}/{file-path}` and renders a
badge-styled link. Reads `params.ananke.shortcodes.edit_page`
(`repo_url`, `branch`, `content_dir`, `target`). Accepts a `Page` or a
`{page, branch}` map.
- **`layouts/_shortcodes/edit-page.html`** — thin shortcode wrapper
following the shortcode style guide (`IsNamedParams`, positional + named
`branch` override, warns when used on a page without a source file).
- **`i18n/en.toml`** — new translatable `editPage` string ("Improve this
page on GitHub").

## Fork support is automatic

Using GitHub's `/edit/` URL means visitors **without** write access are
automatically offered GitHub's built-in "fork and propose changes" flow
on save — no extra logic required.

## Usage

```go-html-template
{{</* edit-page */>}} {{/* configured branch */>}}
{{</* edit-page "main" */>}} {{/* positional branch override */>}}
{{</* edit-page branch="development" */>}} {{/* named branch override */>}}
```

The same partial can be rendered automatically below all content via a
`content-after` hook (done in the documentation repo).

## Notes

- The `content-after` hook only fires on single pages, so section index
(`_index.md`) pages won't show the link unless the hook call is also
added to `list.html`/`home.html`.
- Companion documentation PR added in the `documentation` repo.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 files modified
2 files added
90 ■■■■■ changed files
i18n/en.toml 3 ●●●●● diff | view | raw | blame | history
layouts/_partials/edit-page.html 61 ●●●●● diff | view | raw | blame | history
layouts/_shortcodes/edit-page.html 26 ●●●●● diff | view | raw | blame | history