Skip to content

Add copy entire page as markdown feature to documentation#100

Closed
Copilot wants to merge 5 commits intomainfrom
copilot/add-copy-code-to-markdown
Closed

Add copy entire page as markdown feature to documentation#100
Copilot wants to merge 5 commits intomainfrom
copilot/add-copy-code-to-markdown

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 24, 2026

Implements functionality to copy entire documentation pages as raw Markdown content, addressing user request to copy complete articles rather than just individual code blocks.

Changes Made

New Component

  • apps/docs/components/copy-page-markdown.tsx: Client-side component that handles copying page content to clipboard
    • Uses Navigator Clipboard API for copy functionality
    • Provides visual feedback with state transition: "Copy as Markdown" → "Copied!" (resets after 2 seconds)
    • Styled with Tailwind CSS using consistent design tokens from the documentation theme
    • Uses lucide-react icons (Copy/Check) for visual indicators

Updated Component

  • apps/docs/app/[lang]/docs/[[...slug]]/page.tsx: Server-side page component
    • Reads raw MDX file content directly from filesystem at build/render time
    • Attempts multiple file path patterns to locate the correct MDX file (handles different language versions and directory structures)
    • Passes raw markdown content to the CopyPageMarkdown component as a prop
    • Integrated button into page header layout using flexbox, positioned next to the page title
    • Button only renders when markdown content is successfully loaded

Feature Description

Users can now copy the entire raw Markdown content of any documentation page by clicking the "Copy as Markdown" button located in the top-right corner of each page, adjacent to the page title. This allows users to easily export documentation content for offline use, editing, or sharing.

Button Placement

┌───────────────────────────────────────────────────┐
│  Client SDK          [📋 Copy as Markdown]        │
│  The official TypeScript client for ObjectStack  │
│───────────────────────────────────────────────────│
│  ## Features                                       │
│  - Auto-Discovery                                  │
│  ...                                               │
└───────────────────────────────────────────────────┘

Technical Approach

  1. Server-side reads the raw MDX file content from the filesystem using Node.js fs module
  2. Multiple file path patterns are checked to handle different documentation structures and language variants
  3. Content is passed as a prop to the client-side component
  4. Client component uses the Clipboard API to copy content when button is clicked
  5. Visual feedback is provided through React state management and conditional rendering

Known Pre-existing Issue

⚠️ The documentation site currently has a widespread lucide-react module resolution error that prevents pages from loading in development mode. This issue is not caused by this PR - it is a pre-existing configuration problem where MDX files directly import lucide-react but the server-side rendering context cannot properly resolve the module during compilation.

Error: Module not found: Can't resolve 'lucide-react' appears in multiple files including:

  • content/docs/concepts/*.mdx
  • content/docs/specifications/**/*.mdx
  • content/docs/index.mdx

This configuration issue needs to be resolved separately for the documentation site to function properly. Once fixed, the "Copy as Markdown" feature will work as intended.

Original prompt

文档查看页应支持复制码当markdown


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link
Copy Markdown

vercel bot commented Jan 24, 2026

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

Project Deployment Review Updated (UTC)
spec Error Error Jan 24, 2026 11:30am

Request Review

Copilot AI and others added 2 commits January 24, 2026 10:32
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for copying code as markdown in documentation view Verify code copy functionality in documentation Jan 24, 2026
Copilot AI requested a review from hotlong January 24, 2026 10:36
@hotlong
Copy link
Copy Markdown
Contributor

hotlong commented Jan 24, 2026

@copilot 我的意思是我想把整篇文章复制出来,而不是把其中某一个code,我知道原来那个就有

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 24, 2026

@copilot 我的意思是我想把整篇文章复制出来,而不是把其中某一个code,我知道原来那个就有

明白了!您想要复制整篇文章内容为 Markdown 格式,而不只是代码块。我现在会添加一个"复制整页为 Markdown"的功能。

@xuyushun441-sys
Copy link
Copy Markdown
Contributor

@copilot 继续

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 24, 2026

@copilot 继续

好的,我继续完成"复制整页为 Markdown"的功能实现。

Copilot AI and others added 2 commits January 24, 2026 11:27
Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
Copilot AI changed the title Verify code copy functionality in documentation Add copy entire page as markdown feature to documentation Jan 24, 2026
Copilot AI requested a review from xuyushun441-sys January 24, 2026 11:29
@github-actions github-actions bot added documentation Improvements or additions to documentation size/m labels Jan 24, 2026
@hotlong hotlong closed this Jan 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants