Skip to content

feat: add export or view page as MD#8521

Merged
harsh62 merged 5 commits intomainfrom
export-for-ai
Mar 12, 2026
Merged

feat: add export or view page as MD#8521
harsh62 merged 5 commits intomainfrom
export-for-ai

Conversation

@harsh62
Copy link
Member

@harsh62 harsh62 commented Mar 10, 2026

Description of changes:

Summary

  • Add structured markdown export (llms.txt) for AI coding assistants, following the emerging https://llmstxt.org/
  • Generate llms.txt index, llms-full.txt concatenated export, and individual per-page .md files for all ~285 Gen2 doc pages
  • Add "Use with AI" dropdown button on Gen2 content pages with options to copy page markdown to clipboard or open it in a new tab

Details

Build script (tasks/generate-llms-txt.mjs):

  • Walks directory.json to collect all Gen2 pages (routes under /[platform]/)
  • Transforms MDX to clean markdown: strips exports/imports, converts InlineFilter → HTML comments, BlockSwitcher/Block → headings,
    Callout → blockquotes, Accordion →
    Details, strips Overview/Video/YoutubeEmbed/JSX comments
  • Protects fenced code blocks from regex transforms using placeholder extraction
  • Resolves by reading and inlining referenced fragment MDX files
  • Outputs to public/ai/ — served by Next.js in both dev and production
  • Runs as part of prebuild (after directory.json generation)

UI component (src/components/MarkdownMenu):

  • "Use with AI" button with ✨ emoji and dropdown chevron, positioned right of page heading
  • Two menu items: "Copy page MD" (clipboard) and "Open this page as MD" (new tab)
  • Hidden on Gen1 pages, home page, and overview/index pages
  • Guards against copying HTML if markdown file is unavailable

Instructions

If this PR should not be merged upon approval for any reason, please submit as a DRAFT

Which product(s) are affected by this PR (if applicable)?

  • amplify-cli
  • amplify-ui
  • amplify-studio
  • amplify-hosting
  • amplify-libraries

Which platform(s) are affected by this PR (if applicable)?

  • JS
  • Swift
  • Android
  • Flutter
  • React Native

Please add the product(s)/platform(s) affected to the PR title

Checks

  • Does this PR conform to the styleguide?

  • Does this PR include filetypes other than markdown or images? Please add or update unit tests accordingly.

  • Are any files being deleted with this PR? If so, have the needed redirects been created?

  • Are all links in MDX files using the MDX link syntax rather than HTML link syntax?

    ref: MDX: [link](https://docs.amplify.aws/)
    HTML: <a href="https://docs.amplify.aws/">link</a>

When this PR is ready to merge, please check the box below

  • Ready to merge

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@harsh62 harsh62 requested a review from a team as a code owner March 10, 2026 15:33
bobbor
bobbor previously approved these changes Mar 11, 2026
@harsh62 harsh62 merged commit abc9869 into main Mar 12, 2026
12 checks passed
@harsh62 harsh62 deleted the export-for-ai branch March 12, 2026 13:24
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.

3 participants