Skip to content

Commit 27729a5

Browse files
committed
chore: minor changes
1 parent c1af0b0 commit 27729a5

6 files changed

Lines changed: 45 additions & 140 deletions

File tree

apps/web/app/api/og/_utils.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export async function loadGoogleFont(fontName: string): Promise<ArrayBuffer> {
2+
const fontUrl = `https://fonts.googleapis.com/css2?family=${fontName.replace(' ', '+')}&display=swap`
3+
4+
const response = await fetch(fontUrl)
5+
const cssText = await response.text()
6+
7+
const fontFaceMatch = cssText.match(/@font-face\s*{[^}]*}/)
8+
if (!fontFaceMatch) throw new Error(`Font face not found for ${fontName}`)
9+
10+
const [fontFace] = fontFaceMatch
11+
const urlMatch = fontFace.match(/url\(([^)]+)\)/)
12+
if (!urlMatch) throw new Error(`Font URL not found for ${fontName}`)
13+
14+
const fontFileUrl = urlMatch[1]?.replaceAll(/['"]/g, '')
15+
const fontResponse = await fetch(fontFileUrl ?? '')
16+
return await fontResponse.arrayBuffer()
17+
}

apps/web/app/api/og/docs/[...slug]/route.tsx

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,13 @@
11
import { notFound } from 'next/navigation'
22
import { ImageResponse } from 'next/og'
33

4+
import { loadGoogleFont } from '@/app/api/og/_utils'
45
import { appName } from '@/lib/shared'
56
import { getPageImage, source } from '@/lib/source'
67
import { OpenGraph } from '@/registry/ui/open-graph'
78

89
export const revalidate = false
910

10-
async function loadGoogleFont(fontName: string): Promise<ArrayBuffer> {
11-
const fontUrl = `https://fonts.googleapis.com/css2?family=${fontName.replace(' ', '+')}&display=swap`
12-
13-
const response = await fetch(fontUrl)
14-
const cssText = await response.text()
15-
16-
const fontFaceMatch = cssText.match(/@font-face\s*{[^}]*}/)
17-
if (!fontFaceMatch) throw new Error(`Font face not found for ${fontName}`)
18-
19-
const [fontFace] = fontFaceMatch
20-
const urlMatch = fontFace.match(/url\(([^)]+)\)/)
21-
if (!urlMatch) throw new Error(`Font URL not found for ${fontName}`)
22-
23-
const fontFileUrl = urlMatch[1]?.replaceAll(/['"]/g, '')
24-
const fontResponse = await fetch(fontFileUrl ?? '')
25-
return await fontResponse.arrayBuffer()
26-
}
27-
2811
export async function GET(
2912
req: Request,
3013
{ params }: RouteContext<'/api/og/docs/[...slug]'>

apps/web/app/api/og/route.tsx

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,11 @@
11
import { ImageResponse } from 'next/og'
22

3+
import { loadGoogleFont } from '@/app/api/og/_utils'
34
import { appName } from '@/lib/shared'
45
import { OpenGraph } from '@/registry/ui/open-graph'
56

67
export const revalidate = false
78

8-
async function loadGoogleFont(fontName: string): Promise<ArrayBuffer> {
9-
const fontUrl = `https://fonts.googleapis.com/css2?family=${fontName.replace(' ', '+')}&display=swap`
10-
11-
const response = await fetch(fontUrl)
12-
const cssText = await response.text()
13-
14-
const fontFaceMatch = cssText.match(/@font-face\s*{[^}]*}/)
15-
if (!fontFaceMatch) throw new Error(`Font face not found for ${fontName}`)
16-
17-
const [fontFace] = fontFaceMatch
18-
const urlMatch = fontFace.match(/url\(([^)]+)\)/)
19-
if (!urlMatch) throw new Error(`Font URL not found for ${fontName}`)
20-
21-
const fontFileUrl = urlMatch[1]?.replaceAll(/['"]/g, '')
22-
const fontResponse = await fetch(fontFileUrl ?? '')
23-
return await fontResponse.arrayBuffer()
24-
}
25-
269
export async function GET(req: Request) {
2710
const url = new URL(req.url)
2811

apps/web/components/ui/popover.tsx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
"use client"
1+
'use client'
22

3-
import * as React from "react"
4-
import { Popover as PopoverPrimitive } from "@base-ui/react/popover"
3+
import { Popover as PopoverPrimitive } from '@base-ui/react/popover'
4+
import * as React from 'react'
55

6-
import { cn } from "@/lib/utils"
6+
import { cn } from '@/lib/utils'
77

88
function Popover({ ...props }: PopoverPrimitive.Root.Props) {
9-
return <PopoverPrimitive.Root data-slot="popover" {...props} />
9+
return <PopoverPrimitive.Root data-slot='popover' {...props} />
1010
}
1111

1212
function PopoverTrigger({ ...props }: PopoverPrimitive.Trigger.Props) {
13-
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
13+
return <PopoverPrimitive.Trigger data-slot='popover-trigger' {...props} />
1414
}
1515

1616
function PopoverContent({
1717
className,
18-
align = "center",
18+
align = 'center',
1919
alignOffset = 0,
20-
side = "bottom",
20+
side = 'bottom',
2121
sideOffset = 4,
2222
...props
2323
}: PopoverPrimitive.Popup.Props &
2424
Pick<
2525
PopoverPrimitive.Positioner.Props,
26-
"align" | "alignOffset" | "side" | "sideOffset"
26+
'align' | 'alignOffset' | 'side' | 'sideOffset'
2727
>) {
2828
return (
2929
<PopoverPrimitive.Portal>
@@ -32,12 +32,12 @@ function PopoverContent({
3232
alignOffset={alignOffset}
3333
side={side}
3434
sideOffset={sideOffset}
35-
className="isolate z-50"
35+
className='isolate z-50'
3636
>
3737
<PopoverPrimitive.Popup
38-
data-slot="popover-content"
38+
data-slot='popover-content'
3939
className={cn(
40-
"z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
40+
'data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100',
4141
className
4242
)}
4343
{...props}
@@ -47,11 +47,11 @@ function PopoverContent({
4747
)
4848
}
4949

50-
function PopoverHeader({ className, ...props }: React.ComponentProps<"div">) {
50+
function PopoverHeader({ className, ...props }: React.ComponentProps<'div'>) {
5151
return (
5252
<div
53-
data-slot="popover-header"
54-
className={cn("flex flex-col gap-0.5 text-sm", className)}
53+
data-slot='popover-header'
54+
className={cn('flex flex-col gap-0.5 text-sm', className)}
5555
{...props}
5656
/>
5757
)
@@ -60,8 +60,8 @@ function PopoverHeader({ className, ...props }: React.ComponentProps<"div">) {
6060
function PopoverTitle({ className, ...props }: PopoverPrimitive.Title.Props) {
6161
return (
6262
<PopoverPrimitive.Title
63-
data-slot="popover-title"
64-
className={cn("font-medium", className)}
63+
data-slot='popover-title'
64+
className={cn('font-medium', className)}
6565
{...props}
6666
/>
6767
)
@@ -73,8 +73,8 @@ function PopoverDescription({
7373
}: PopoverPrimitive.Description.Props) {
7474
return (
7575
<PopoverPrimitive.Description
76-
data-slot="popover-description"
77-
className={cn("text-muted-foreground", className)}
76+
data-slot='popover-description'
77+
className={cn('text-muted-foreground', className)}
7878
{...props}
7979
/>
8080
)

apps/web/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,13 @@
2323
"clsx": "^2.1.1",
2424
"fumadocs-core": "16.8.9",
2525
"fumadocs-mdx": "15.0.2",
26-
"fumadocs-ui": "^16.8.9",
2726
"lucide-react": "^1.14.0",
2827
"marked": "^18.0.3",
2928
"next": "16.2.6",
3029
"react": "catalog:react",
3130
"react-dom": "catalog:react",
3231
"tailwind-merge": "^3.6.0",
33-
"zod": "catalog:prod",
34-
"@radix-ui/react-popover": "^1.1.15"
32+
"zod": "catalog:prod"
3533
},
3634
"devDependencies": {
3735
"@opennextjs/cloudflare": "^1.19.9",
@@ -48,4 +46,4 @@
4846
"tailwindcss": "catalog:tailwind",
4947
"typescript": "catalog:dev"
5048
}
51-
}
49+
}

0 commit comments

Comments
 (0)