Skip to content

Commit

Permalink
add className option to Code, add max-w-max when in hero.saas
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchuman committed Jan 18, 2025
1 parent 35959c6 commit 05e2523
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/ui/modules/HeroSaaS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export default function HeroSaaS({
value={content}
components={{
types: {
code: Code,
code: ({ value }) => (
<Code className="mx-auto max-w-max" value={value} />
),
'custom-html': ({ value }) => <CustomHTML {...value} />,
'reputation-block': ({ value }) => (
<Reputation
Expand Down
6 changes: 4 additions & 2 deletions src/ui/modules/RichtextModule/Code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ import ClickToCopy from '@/ui/ClickToCopy'
import css from './Code.module.css'
import { cn } from '@/lib/utils'
import { stegaClean } from 'next-sanity'
import type { ComponentProps } from 'react'

export default async function Code({
value,
className,
}: {
value?: {
language: string
code: string
filename?: string
highlightedLines?: number[]
}
}) {
} & ComponentProps<'article'>) {
if (!value?.code) return null

const html = await codeToHtml(stegaClean(value.code), {
Expand All @@ -34,7 +36,7 @@ export default async function Code({

return (
<article
className="group relative !mb-2 !mt-6 rounded bg-ink/5"
className={cn('group relative !mb-2 !mt-6 rounded bg-ink/5', className)}
data-module="code"
>
{value.filename && (
Expand Down

0 comments on commit 05e2523

Please sign in to comment.