Skip to content

Feat:Add a copy README as markdown button on pages/package#1058

Open
carwack wants to merge 9 commits intonpmx-dev:mainfrom
carwack:feat/add-pages-package-readme-button
Open

Feat:Add a copy README as markdown button on pages/package#1058
carwack wants to merge 9 commits intonpmx-dev:mainfrom
carwack:feat/add-pages-package-readme-button

Conversation

@carwack
Copy link

@carwack carwack commented Feb 5, 2026

This should solve: #1020

I did implement it the way I understood it and took my inspiration from the Ark UI docs.
This PR adds a new copy README as markdown button for the README on a package page. This makes it possible to have the README content as markdown in the users clipboard.

Screen.Recording.2026-02-06.at.00.06.26.mov

I have also added the translations for the following languages:

  • EN
  • fr-FR
  • de-DE
  • es
  • it-IT

@vercel
Copy link

vercel bot commented Feb 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Feb 5, 2026 11:42pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Feb 5, 2026 11:42pm
npmx-lunaria Ignored Ignored Feb 5, 2026 11:42pm

Request Review

@github-actions
Copy link

github-actions bot commented Feb 5, 2026

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
lunaria/files/de-DE.json Localization changed, will be marked as complete.
lunaria/files/en-GB.json Localization changed, will be marked as complete.
lunaria/files/en-US.json Source changed, localizations will be marked as outdated.
lunaria/files/es-419.json Localization changed, will be marked as complete.
lunaria/files/es-ES.json Localization changed, will be marked as complete.
lunaria/files/fr-FR.json Localization changed, will be marked as complete.
lunaria/files/it-IT.json Localization changed, will be marked as complete.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 8.33333% with 11 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/pages/package/[...package].vue 8.33% 9 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

ReadmeResponse gained a new md: string property and renderReadmeHtml now returns the original Markdown in md. The package README page component exposes readmeData.md, adds a "Copy as Markdown" clipboard action with a temporary copied state, integrates the control into the README header alongside the existing TOC dropdown, and updates button labels/aria attributes. New i18n keys copy_as_markdown were added across locale and lunaria files. Unit tests were added to assert md contains the original markdown and html is sanitized.

Possibly related PRs

Suggested reviewers

  • danielroe
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The PR description clearly relates to the changeset, describing the addition of a copy README as markdown button with translations for multiple languages.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
i18n/locales/en.json (1)

213-226: ⚠️ Potential issue | 🟡 Minor

Capitalise “Markdown” in the label.
Minor copy consistency for a proper noun.

✏️ Proposed copy tweak
-      "copy_as_markdown": "Copy README as markdown"
+      "copy_as_markdown": "Copy README as Markdown"
🧹 Nitpick comments (2)
server/utils/readme.ts (1)

272-272: Consider making raw markdown lazy to avoid payload bloat.
Shipping both HTML and raw Markdown can nearly double response size for large READMEs. If this becomes a performance concern, consider fetching md on demand (or behind a flag) instead of always returning it.

Also applies to: 456-459

app/pages/package/[...package].vue (1)

1139-1172: Clean implementation of the copy button UI.

The button is correctly guarded by v-if="readmeData?.md" and integrates well alongside the existing TOC dropdown. Accessibility attributes are properly applied.

Two minor observations:

  1. Redundant disabled attribute (Line 1149): Since the parent TooltipApp already has v-if="readmeData?.md", the button only renders when md is truthy, making :disabled="!readmeData?.md" always evaluate to false. Consider removing it or keeping it for defensive coding if the structure might change.

  2. Overlapping CSS classes (Lines 1150-1153): The static class includes text-fg-subtle hover:text-fg, which duplicates the dynamic :class binding for the non-copied state. This is harmless but could be tidied up.

♻️ Optional: Remove redundant disabled and consolidate classes
               <button
                 type="button"
                 `@click`="copyReadme()"
-                :disabled="!readmeData?.md"
-                class="px-2 py-1.5 font-mono text-xs rounded transition-colors duration-150 text-fg-subtle hover:text-fg inline-flex items-center gap-1.5"
-                :class="
-                  copiedReadme ? 'text-accent bg-accent/10' : 'text-fg-subtle bg-bg hover:text-fg'
-                "
+                class="px-2 py-1.5 font-mono text-xs rounded transition-colors duration-150 inline-flex items-center gap-1.5"
+                :class="copiedReadme ? 'text-accent bg-accent/10' : 'text-fg-subtle bg-bg hover:text-fg'"
                 :aria-label="
                   copiedReadme ? $t('common.copied') : $t('package.readme.copy_as_markdown')
                 "

Based on learnings: The copy button pattern in this file is acceptable inline with the CSS-only approach for smooth animations; a reusable component may be introduced in the future.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Copy link

@ghostdevv ghostdevv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love it! I think your PR title needs casing correctly, I unfortunately don't have such powers

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