Skip to content

Feature/code block component#673

Merged
0xharkirat merged 13 commits intomainfrom
feature/code-block-component
Feb 18, 2026
Merged

Feature/code block component#673
0xharkirat merged 13 commits intomainfrom
feature/code-block-component

Conversation

@0xharkirat
Copy link
Member

@0xharkirat 0xharkirat commented Feb 18, 2026

Part of #589

This PR introduces a new Code Block Component matching the implementation in , as discussed with @joshbermanssw.

It replaces the previous partial solution with a fully custom, syntax-highlighted component powered by Shiki (v3).

🚀 Key Features

  • Advanced Highlighting: Implementing v3 with theme for accurate VS Code-like syntax highlighting.
  • Transformers Support:
    • Diffs: // [code wikipedia_reader ++] and // [code wikipedia_reader --]
    • Highlighting: // [code wikipedia_reader highlight]
    • Focus mode: // [code wikipedia_reader focus]
  • Better UX: Added a Skeleton Loader for smoother loading without layout shifts and a Copy Button with success feedback.
  • Performance: Uses a Singleton Pattern to lazy-load languages on the client, keeping the initial bundle size small.

🛠️ Changes

  • New Components:
    • code-block.tsx: Main client component with robust error handling and HTML sanitization.
    • code-block-skeleton.tsx: Deterministic shimmer loader to prevent hydration mismatches.
    • shiki-singleton.tsx: Utility to manage highlighter lifecycle and dynamic language loading.
  • Styling: Added code-block.css for specific token styling (diffs, line numbers, scrolling).
  • Dependencies: Added shiki and @shikijs/transformers.
    • Note: pnpm-lock.yaml shows both shiki@1.x (via TinaCMS/TypeDoc) and our shiki@3.x. This duplication is necessary for our feature requirements.
  • Layout: Adjusted docs layout grid for better sidebar sizing.

🧪 Verification

  • Added a temporary test page (test-code-block.mdx) to verify rendering across multiple languages.
Screenshot 2026-02-18 at 4 18 47 pm Screenshot 2026-02-18 at 4 18 55 pm Figure: Updated code blocks with Shiki (as implemented in tinadocs)

@vercel
Copy link

vercel bot commented Feb 18, 2026

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

Project Deployment Actions Updated (UTC)
ssw-products Ready Ready Preview, Comment Feb 18, 2026 11:24pm

Request Review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Introduces a reusable CodeBlock component and wires it into TinaMarkdown rendering so documentation code snippets get syntax highlighting and copy-to-clipboard support, plus a docs-only verification page and a small docs layout tweak.

Changes:

  • Added components/shared/CodeBlock.tsx and integrated it into tina/tinamarkdownStyles/DocAndBlogMarkdownStyle.tsx for rendering fenced code blocks.
  • Added react-syntax-highlighter (and types) dependencies and a /docs/test-code-block MDX page for manual verification.
  • Updated docs layout grid sidebar widths and applied a minor MDX formatting cleanup.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
utils/cn.ts New cn helper added (duplicates existing helper).
tina/tinamarkdownStyles/DocAndBlogMarkdownStyle.tsx Routes TinaMarkdown code blocks to the new CodeBlock renderer.
components/shared/CodeBlock.tsx New client component for highlighted code + copy button.
content/docs/EagleEye/test-code-block.mdx Adds a documentation page to visually test code blocks.
content/docs/EagleEye/prerequisites.mdx Minor formatting cleanup.
app/[product]/docs/layout.tsx Adjusts docs grid columns for fixed-width sidebar.
package.json Adds syntax highlighting dependencies.
pnpm-lock.yaml Lockfile updates for new dependencies.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 10 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

content/docs/EagleEye/prerequisites.mdx:22

  • Typo in the newly added code block content: someting should be something.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…ut` cleanup, and conditional border, and add Shiki highlighter fallback on initialization failure.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

…xt code blocks, and add explicit prop types to the skeleton component.
@0xharkirat
Copy link
Member Author

Do not merge automatically need to remove test file docs/test-code-block

@0xharkirat 0xharkirat merged commit e419680 into main Feb 18, 2026
2 checks passed
@0xharkirat 0xharkirat deleted the feature/code-block-component branch February 18, 2026 23:25
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