From e1dcf42746b5446b31103588fda218b1d8847c94 Mon Sep 17 00:00:00 2001 From: Vojta Holik Date: Thu, 9 Jan 2025 16:18:51 +0100 Subject: [PATCH] feat(aih): special treatment for shellscript code blocks (#370) --- .../ai-hero/src/app/(content)/[post]/page.tsx | 2 +- apps/ai-hero/src/components/codehike/code.tsx | 36 +++++++++++++++---- .../src/components/codehike/copy-button.tsx | 26 ++++++++++++++ 3 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 apps/ai-hero/src/components/codehike/copy-button.tsx diff --git a/apps/ai-hero/src/app/(content)/[post]/page.tsx b/apps/ai-hero/src/app/(content)/[post]/page.tsx index 96232932c..894bf5c02 100644 --- a/apps/ai-hero/src/app/(content)/[post]/page.tsx +++ b/apps/ai-hero/src/app/(content)/[post]/page.tsx @@ -120,7 +120,7 @@ async function Post({ post }: { post: Post | null }) { }) return ( -
+
{content}
) diff --git a/apps/ai-hero/src/components/codehike/code.tsx b/apps/ai-hero/src/components/codehike/code.tsx index 6901bdd6b..05debcef2 100644 --- a/apps/ai-hero/src/components/codehike/code.tsx +++ b/apps/ai-hero/src/components/codehike/code.tsx @@ -1,16 +1,40 @@ import React from 'react' import { highlight, Pre, RawCode } from 'codehike/code' +import { cn } from '@coursebuilder/ui/utils/cn' + +import { CopyButton } from './copy-button' import { callout, diff, focus, fold, link, mark } from './handlers' export async function Code({ codeblock }: { codeblock: RawCode }) { const highlighted = await highlight(codeblock, 'github-dark') + const isTerminalCode = highlighted.lang === 'shellscript' return ( -
+		
+ {isTerminalCode && ( +