Skip to content

Add docusaurus-plugin-copy-page-button - #342

Closed
portdeveloper wants to merge 1 commit into
osmosis-labs:mainfrom
portdeveloper:add-copy-page-button
Closed

Add docusaurus-plugin-copy-page-button#342
portdeveloper wants to merge 1 commit into
osmosis-labs:mainfrom
portdeveloper:add-copy-page-button

Conversation

@portdeveloper

Copy link
Copy Markdown

This PR

  • adds docusaurus-plugin-copy-page-button to package.json
  • adds the plugin string to plugins in docusaurus.config.ts
  • puts a "Copy page" button in the docs sidebar — exports current page as clean markdown
  • adds one-click "Open in Claude / ChatGPT / Gemini" actions that prefill the markdown

why useful for Osmosis specifically:
the integrate/ and validate/ sections carry a lot of per-page nuance — pools, IBC transfers, CosmWasm, running and upgrading nodes. the typical flow for someone building against Osmosis or standing up a validator is reading a docs page → wanting to drop just that page into an LLM to scaffold the integration or debug a setup. this saves the selection-and-cleanup step.

zero config, auto-injects into the TOC sidebar, theme-aware. (noticed you swizzle DocSidebar — the button injects near the TOC on the right, so it won't touch your left-nav customizations.)

shipping on React Native, Redux Toolkit, Puppeteer, pnpm, PlayCanvas, Arbitrum, Cardano, Sui, Nillion, Flare, Kaia, and ~20 other docs sites. listed on the Docusaurus community plugins page.

happy to close/rebase if not a fit

@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

@portdeveloper is attempting to deploy a commit to the OsmoLabs Team on Vercel.

A member of the Team first needs to authorize it.

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addeddocusaurus-plugin-copy-page-button@​0.8.17810010096100

View full report

@JohnnyWyles

Copy link
Copy Markdown
Collaborator

Thanks for this, and for the clear writeup. The underlying goal (making the docs easy to hand to an LLM) is one we care about and will address once the current content pass is finished.

Not 100% on the need to expose this to a user to then copy across to an LLM. At the moment, we're looking more at ways to make the docs work better without a human intermediary, rather than simplifying by having a human copy across pages into context.

On review, generateMarkdownRoutes is the feature that would help with this, but it's off by default and didn't work on our setup. When we enabled generateMarkdownRoutes: true and rebuilt, it emitted zero .md files.

We're going to hold this PR for now, rather than merge the button alone, until after the content sweep, and look into alternative methods for making docs more palatable to LLMs for comparison.

@portdeveloper

Copy link
Copy Markdown
Author

appreciate the detailed feedback — the "no human intermediary" framing is the right one, and generateMarkdownRoutes is exactly the piece for that, so the zero-files thing was a real bug worth chasing.

dug into it: your site sets trailingSlash: false, so docusaurus emits flat <route>.html files instead of the default <route>/index.html. the markdown generator only looked for the nested form, so fs.existsSync missed every page and it silently wrote nothing. the build "succeeded" with zero output, which is why it looked like a no-op rather than an error.

fixed in 0.8.3 (just published) — it now resolves both layouts. i reproduced it on a clone of this branch: with 0.8.3 + generateMarkdownRoutes: true, it went from 0 to 117 .md files, each with the page title, canonical url, and content. no button or human copy-paste involved — just per-page markdown at /<route>.md for whatever consumes it.

totally reasonable to hold until after the content sweep. whenever you revisit, bumping to ^0.8.3 and flipping generateMarkdownRoutes: true should give you the machine-readable routes to compare against the other approaches. happy to help wire it up if useful.

@JohnnyWyles

Copy link
Copy Markdown
Collaborator

Wanted to be straight with you about where we landed, since you put real work in here. We added a small first-party build step (now merged: #351). It generates the same thing, per-page <route>.md plus an llms.txt index, but reads our source markdown directly rather than post-processing the built HTML, which lets us handle a few site-specific things (rewriting relative links and image paths to the shifted route depth, expanding our DocCardList landing pages into child lists, and stripping only the MDX chrome that isn't in code fences). Keeping it in-repo with no added dependency also fit this repo's constraints.

Thank you for raising this with us and the contribution though, this was real missing functionality that if we hadn't had on the radar already would have been really useful with the increasing usage of LLMs for most work.

pull Bot pushed a commit to moul/docs that referenced this pull request Jul 31, 2026
Add scripts/gen-llms.mjs (run as a postbuild step) that reads the source
markdown under docs/ and emits, into the build output:
  - build/<route>.md  a clean plain-markdown copy of every page, served
    raw at the page URL + .md (no nav chrome, no JS)
  - build/llms.txt    a grouped index of every page and its .md URL

Source-derived rather than HTML-scraped, so it is robust against our
swizzled routeBasePath:'/' theme (the approach that produced zero output
for the scraping-based plugin in PR osmosis-labs#342). Strips MDX chrome (theme
imports, Tabs/TabItem, <p align> image wrappers, admonition fences) only
outside code fences, so placeholder tokens and code examples survive.

Correctness of the generated corpus:
  - Rewrites relative links/images to absolute paths, since index/README
    pages are served one directory shallower than their source file.
    Inter-page links point at the target's .md (not the HTML route) so an
    agent following a link stays in the markdown corpus; images map to the
    hashed asset Docusaurus emits under /assets/images.
  - Expands <DocCardList/> into a markdown list of child pages (title +
    description, linked to each child's .md) so section-landing navigation
    is preserved.
  - Adds llms.txt entries for content routes outside docs/ (home, /api,
    which have no markdown source) and reports honest sitemap coverage
    (with-markdown vs indexed-HTML-only vs excluded vs uncovered),
    deliberately excluding utility routes (/search, /api/v2,
    /category/key-management).

build/ is gitignored, so only the generator is tracked.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants