-
Notifications
You must be signed in to change notification settings - Fork 2k
Feature: Add copy as markdown button to docs #3290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Add copy as markdown button to docs #3290
Conversation
Howdy @kamilmysliwiec ,
I wanted to contribute to the NestJS docs by adding a copy-as-markdown button. To avoid large bundle sizes or API calls, I'm exploring generating cleaned Markdown files as static assets during the build process that we could use as the source for the copying.
However, I stumbled upon an architectural issue. The feature breaks on pages with routing redirects because the URL path doesn't match the markdown filename. The redirects for the HTML pages are defined at the feature module level.
For example:
URL: /fundamentals/custom-providers
Serves content from: dependency-injection.md
The copy-as-markdown function tries to fetch: /assets/content/fundamentals/custom-providers.md
, which results in a 404
.
The root cause is that Dgeni generates Markdown files based on original filenames, but Angular routing redirects create different final URLs. There are 6+ routing modules with various redirects.
If you find this feature valuable, I'd happy to get your feedback on what you think could be a good way to get around that challenge. I am thinking perhaps adding redirects that the assets that match the redirects defined in the feature module.
Thank you for your time and insight 🙏
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
Currently, users have no way to easily copy documentation content as clean, portable Markdown. When users want to share or reference NestJS documentation content with LLMs, they must manually copy HTML content or recreate the formatting themselves.
What is the new behavior?
Adds a "Copy as Markdown" button to every documentation page that allows users to copy clean, portable Markdown content to their clipboard. The copied content includes:
Features:
Does this PR introduce a breaking change?
Other information
Implementation approach:
npm run build:watch
workflowTechnical details:
OutputCleanMarkdownProcessor
to Dgeni pipelinesrc/assets/content/
and gitignored (like existing HTML templates)BasePageComponent
(used by all doc pages)Browser support: Modern browsers with Clipboard API (Chrome, Firefox, Safari, Edge)