feat: add Copy page and View buttons on guide pages#22
Open
Zodiarche wants to merge 4 commits into
Open
Conversation
NuriYuri
requested changes
May 14, 2026
Add a small set of two buttons in the top-right of each guide article: - Copy page: fetches the raw markdown for the current URL and writes it to the clipboard (briefly switches to 'Copied!' as feedback). - View: opens the raw markdown in a new tab. A custom Docusaurus plugin (plugins/raw-markdown.js) writes a clean .md file (frontmatter stripped) for every doc into the build output at the same URL path as the rendered page, in both locales: /psdk/battle-engine/how-to-create-a-weather.md (English source) /fr/psdk/battle-engine/creer-une-meteo-et-ses-effets.md (French translation, with its localized slug). The buttons only render on guide pages — not on the homepage and not on auto-generated category index pages — by checking metadata.sourceDirName in the swizzled DocItem/Layout. Closes #19
Add Biome 2.4.16 as the linter/formatter for the TS/JS/CSS layer, with lineEnding set to lf. Provides bun run lint/format/check scripts. Format the files touched by this PR; a full-repo format and CI gate are left as a follow-up.
Replace the frontmatter regex with startsWith/indexOf/slice (assuming LF, now enforced via .gitattributes), and replace the manual stack-based directory walk with fs.globSync plus a small toUrlPath helper. Addresses review feedback on plugins/raw-markdown.js.
95691f4 to
c9b013e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add two compact buttons in the top-right of every guide page:
A custom Docusaurus plugin (
plugins/raw-markdown.js) writes a clean.mdfile (frontmatter stripped) for every doc into the build output at the same URL path as the rendered page, in both locales:/psdk/battle-engine/how-to-create-a-weather.md(English source)/fr/psdk/battle-engine/creer-une-meteo-et-ses-effets.md(French translation with its localized slug)The buttons only render on guide pages — not on the homepage, not on auto-generated category index pages — by checking
metadata.sourceDirNamein the swizzledDocItem/Layout.Picked over the existing
docusaurus-markdown-source-plugin(briefly tried) because that one ships a hardcoded "Open Markdown" dropdown on every doc page including the home, with no config to disable the UI or scope it to guides.Related issues
Closes #19
Test plan
bun run typecheckpassesbun run buildpasses (both locales) — plugin reports[raw-markdown] en: copied 46 markdown filesand same for fr/psdk/battle-engine/how-to-create-a-weather.md✓/fr/psdk/battle-engine/creer-une-meteo-et-ses-effets.md(localized slug) ✓<page>.mdURL fetch returns the raw markdown (frontmatter stripped) with status 200, in both localesScreenshots