Skip to content

improvement(docs): added a copy page button to the docs pages#1743

Merged
waleedlatif1 merged 2 commits intostagingfrom
sim-292
Oct 27, 2025
Merged

improvement(docs): added a copy page button to the docs pages#1743
waleedlatif1 merged 2 commits intostagingfrom
sim-292

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

added a copy page button to the docs pages

Type of Change

  • New feature

Testing

Tested manually.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Oct 27, 2025

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

Project Deployment Preview Comments Updated (UTC)
docs Ready Ready Preview Comment Oct 27, 2025 10:06pm

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

Added a "Copy page" button to documentation pages that allows users to quickly copy the full page content (title, description, and body) to their clipboard. The button is positioned in the top-right corner of the page header and provides visual feedback when content is copied.

Key changes:

  • Created new CopyPageButton client component with copy-to-clipboard functionality and timeout-based state reset
  • Integrated button into docs page header using absolute positioning
  • Button copies formatted markdown string containing page title, description, and content
  • Follows existing patterns from CodeBlock component for copy functionality
  • Uses proper accessibility labels and error handling

Confidence Score: 4/5

  • This PR is safe to merge with minor considerations
  • The implementation is clean and follows established patterns in the codebase. The button component has proper error handling, accessibility labels, and state management. The only minor consideration is that page.data.content may not be available for all page types, but this is handled with a fallback empty string.
  • No files require special attention - verify that the copy button appears correctly and the content format meets user expectations

Important Files Changed

File Analysis

Filename Score Overview
apps/docs/app/[lang]/[[...slug]]/page.tsx 4/5 Added copy page button to docs header with proper positioning and content formatting
apps/docs/components/ui/copy-page-button.tsx 5/5 Clean client-side button component with proper state management, error handling, and accessibility

Sequence Diagram

sequenceDiagram
    participant User
    participant Browser
    participant DocsPage
    participant CopyPageButton
    participant Clipboard

    User->>Browser: Visits documentation page
    Browser->>DocsPage: Render page component
    DocsPage->>DocsPage: Load page.data (title, description, content)
    DocsPage->>CopyPageButton: Render with formatted content string
    CopyPageButton->>Browser: Display "Copy page" button
    
    User->>CopyPageButton: Click copy button
    CopyPageButton->>Clipboard: navigator.clipboard.writeText(content)
    Clipboard-->>CopyPageButton: Success/Error
    
    alt Copy successful
        CopyPageButton->>CopyPageButton: setCopied(true)
        CopyPageButton->>Browser: Display "Copied" with check icon
        Note over CopyPageButton: Wait 2000ms
        CopyPageButton->>CopyPageButton: setCopied(false)
        CopyPageButton->>Browser: Display "Copy page" with copy icon
    else Copy failed
        CopyPageButton->>Browser: console.error('Failed to copy')
    end
Loading

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit 8620ab2 into staging Oct 27, 2025
3 of 4 checks passed
@waleedlatif1 waleedlatif1 deleted the sim-292 branch October 27, 2025 22:05
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.

1 participant