Skip to content

Commit 796a408

Browse files
committed
feat: add logo components and improve header with logo; update metadata for Open Graph
1 parent f4d1616 commit 796a408

5 files changed

Lines changed: 86 additions & 5 deletions

File tree

apps/website/src/app/docs/[folder]/[...slug]/page.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ import type { Metadata } from "next";
33
import { globals } from "@/globals";
44
import { notFound } from "next/navigation";
55

6-
import MDX from "@/components/mdx";
76
import { cn } from "@/utils/cn";
87
import { getDocument } from "@/utils/docs";
98

10-
import Article from "@/components/docs/doc-article";
9+
import MDX from "@/components/mdx";
1110
import Container from "@/components/container";
11+
import Article from "@/components/docs/doc-article";
12+
13+
import DocOptions from "@/components/docs/doc-options";
1214
import TableOfContents from "@/components/docs/toc-menu";
1315
import ShowCategories from "@/components/docs/show-categories";
14-
import DocOptions from "@/components/docs/doc-options";
1516

1617
interface DocsPageProps {
1718
params: Promise<{ folder: string; slug: string[] }>;
@@ -22,13 +23,29 @@ export async function generateMetadata({
2223
}: DocsPageProps): Promise<Metadata> {
2324
const { folder, slug } = await params;
2425
const document = slug.join("/");
26+
const websiteUrl = "https://code-blocks.pheralb.dev";
2527
const data = getDocument({
2628
folder,
2729
document,
2830
});
2931
return {
3032
title: `${data?.title} - ${globals.title}`,
3133
description: data?.description,
34+
openGraph: {
35+
type: "website",
36+
url: new URL(`/${slug}`, websiteUrl),
37+
title: `${data?.title} - ${globals.title}`,
38+
description: data?.description,
39+
siteName: websiteUrl,
40+
images: [
41+
{
42+
url: new URL(
43+
`/api/docs/og?document=${document}&folder=${folder}`,
44+
websiteUrl,
45+
),
46+
},
47+
],
48+
},
3249
};
3350
}
3451

apps/website/src/app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const Home = () => {
1818
<>
1919
<Container>
2020
<Header layout="app" />
21-
<Article className="pb-12">
21+
<Article className="pb-14">
2222
<MDX code={document.mdx} />
2323
</Article>
2424
</Container>

apps/website/src/components/header.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import GithubLink from "@/components/github-link";
55
import SponsorLink from "@/components/sponsor-link";
66
import ThemeToggle from "@/components/theme-toggle";
77
import SearchDocs from "@/components/docs/search-docs";
8+
import { LogoWithoutBg } from "./logo";
89

910
interface HeaderProps {
1011
layout: "docs" | "app";
@@ -26,11 +27,13 @@ const Header = ({ layout }: HeaderProps) => {
2627
<Link
2728
href="/"
2829
className={cn(
30+
"flex items-center space-x-2.5",
2931
"text-xl font-semibold tracking-tight transition-colors",
3032
"hover:text-neutral-700 dark:hover:text-neutral-300",
3133
)}
3234
>
33-
Code Blocks
35+
<LogoWithoutBg width={20} height={20} className="shrink-0" />
36+
<span>Code Blocks</span>
3437
</Link>
3538
<div className="flex items-center gap-4">
3639
<SearchDocs />

apps/website/src/components/hero.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const Hero = () => {
1414
className={cn(
1515
"not-prose",
1616
"flex flex-col space-y-4 pt-10 pb-6 md:pt-12 md:pb-10",
17+
"animate-in fill-mode-backwards fade-in slide-in-from-bottom-4 duration-500",
1718
)}
1819
>
1920
<div className="flex flex-col items-center justify-center space-y-2">
@@ -27,6 +28,7 @@ const Hero = () => {
2728
<div
2829
className={cn(
2930
"flex flex-col items-center justify-center space-y-2 md:flex-row md:space-y-0 md:space-x-2",
31+
"animate-in fill-mode-backwards fade-in slide-in-from-bottom-4 duration-500 delay-100",
3032
)}
3133
>
3234
<Link
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import type { SVGProps } from "react";
2+
3+
const LogoWithBg = (props: SVGProps<SVGSVGElement>) => {
4+
return (
5+
<svg
6+
xmlns="http://www.w3.org/2000/svg"
7+
fill="none"
8+
viewBox="0 0 512 512"
9+
{...props}
10+
>
11+
<rect
12+
width="512"
13+
height="512"
14+
x="0"
15+
y="0"
16+
fill="url(#logo-gradient)"
17+
stroke="#FFF"
18+
strokeOpacity="100%"
19+
strokeWidth="0"
20+
paintOrder="stroke"
21+
rx="128"
22+
/>
23+
<defs>
24+
<radialGradient
25+
id="logo-gradient"
26+
cx="50%"
27+
cy="50%"
28+
r="100%"
29+
fx="50%"
30+
fy="0%"
31+
gradientUnits="objectBoundingBox"
32+
>
33+
<stop stopColor="#171717" />
34+
<stop offset="1" />
35+
</radialGradient>
36+
</defs>
37+
<g transform="translate(80, 80)">
38+
<path
39+
fill="#E6E6E6"
40+
transform="scale(1.375)"
41+
d="m96 73-61.94 55L96 183a12 12 0 1 1-16 18L8 137a12 12 0 0 1 0-18l72-64a12 12 0 0 1 16 18m152 46-72-64a12 12 0 1 0-16 18l61.91 55L160 183a12 12 0 1 0 16 18l72-64a12 12 0 0 0 0-18"
42+
/>
43+
</g>
44+
</svg>
45+
);
46+
};
47+
48+
const LogoWithoutBg = (props: SVGProps<SVGSVGElement>) => {
49+
return (
50+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" {...props}>
51+
<path
52+
fill="currentColor"
53+
d="m96 73-61.94 55L96 183a12 12 0 1 1-16 18L8 137a12 12 0 0 1 0-18l72-64a12 12 0 0 1 16 18m152 46-72-64a12 12 0 1 0-16 18l61.91 55L160 183a12 12 0 1 0 16 18l72-64a12 12 0 0 0 0-18"
54+
></path>
55+
</svg>
56+
);
57+
};
58+
59+
export { LogoWithBg, LogoWithoutBg };

0 commit comments

Comments
 (0)