Skip to content

docs: add copy button to code blocks #343

Description

@yashksaini-coder

Problem

The documentation pages render commands and code snippets in styled code blocks, but there is no way to copy the text with one click. Users must manually select the text to copy it, which is error-prone (especially for long commands like tau --resume <session-id>).

Proposed solution

Add a Copy button that appears on hover in the top-right corner of every <pre> block inside the docs content area. Clicking it copies the code to the clipboard via navigator.clipboard.writeText() and gives a brief "Copied!" visual confirmation.

Changes required:

  • website/assets/js/copy-code.js — new script: walks .docs-content pre blocks on DOMContentLoaded, injects a <button class="copy-btn"> into each, wires the clipboard write + feedback.
  • website/assets/css/main.css — styles for .copy-btn: absolutely positioned top-right, hidden until the parent pre is hovered, flashes green on success.
  • website/layouts/doc/single.html — adds a scripts block to load the JS only on doc pages (no impact on landing or other page types).

No new dependencies. No changes to markdown content or build pipeline.

Screenshots

See the yellow hollow boxes in the attached screenshots — those are the spots where the copy button should appear.

Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions