Skip to content

Commit 8940ed1

Browse files
authored
feat(docs): add unique per-page titles for SEO (#106)
1 parent 4dd0df0 commit 8940ed1

File tree

3 files changed

+40
-19
lines changed

3 files changed

+40
-19
lines changed

packages/docs/src/App.tsx

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,109 +37,125 @@ export const routes: RouteDefinition[] = [
3737
route({
3838
path: "/getting-started",
3939
component: (
40-
<Layout>
40+
<Layout title="Getting Started">
4141
{defer(<GettingStarted />, { name: "GettingStarted" })}
4242
</Layout>
4343
),
4444
}),
4545
route({
4646
path: "/getting-started/migrating-from-vite-spa",
4747
component: (
48-
<Layout>
48+
<Layout title="Migrating from Vite SPA">
4949
{defer(<MigratingFromViteSPA />, { name: "MigratingFromViteSPA" })}
5050
</Layout>
5151
),
5252
}),
5353
route({
5454
path: "/faq",
55-
component: <Layout>{defer(<FAQ />, { name: "FAQ" })}</Layout>,
55+
component: (
56+
<Layout title="FAQ">{defer(<FAQ />, { name: "FAQ" })}</Layout>
57+
),
5658
}),
5759
route({
5860
path: "/api/funstack-static",
5961
component: (
60-
<Layout>
62+
<Layout title="funstackStatic()">
6163
{defer(<FunstackStaticApi />, { name: "FunstackStaticApi" })}
6264
</Layout>
6365
),
6466
}),
6567
route({
6668
path: "/api/defer",
67-
component: <Layout>{defer(<DeferApi />, { name: "DeferApi" })}</Layout>,
69+
component: (
70+
<Layout title="defer()">
71+
{defer(<DeferApi />, { name: "DeferApi" })}
72+
</Layout>
73+
),
6874
}),
6975
route({
7076
path: "/api/build-entry",
7177
component: (
72-
<Layout>{defer(<BuildEntryApi />, { name: "BuildEntryApi" })}</Layout>
78+
<Layout title="BuildEntryFunction">
79+
{defer(<BuildEntryApi />, { name: "BuildEntryApi" })}
80+
</Layout>
7381
),
7482
}),
7583
route({
7684
path: "/api/entry-definition",
7785
component: (
78-
<Layout>
86+
<Layout title="EntryDefinition">
7987
{defer(<EntryDefinitionApi />, { name: "EntryDefinitionApi" })}
8088
</Layout>
8189
),
8290
}),
8391
route({
8492
path: "/learn/how-it-works",
8593
component: (
86-
<Layout>{defer(<HowItWorks />, { name: "HowItWorks" })}</Layout>
94+
<Layout title="How It Works">
95+
{defer(<HowItWorks />, { name: "HowItWorks" })}
96+
</Layout>
8797
),
8898
}),
8999
route({
90100
path: "/learn/rsc",
91101
component: (
92-
<Layout>{defer(<RSCConcept />, { name: "RSCConcept" })}</Layout>
102+
<Layout title="React Server Components">
103+
{defer(<RSCConcept />, { name: "RSCConcept" })}
104+
</Layout>
93105
),
94106
}),
95107
route({
96108
path: "/learn/optimizing-payloads",
97109
component: (
98-
<Layout>
110+
<Layout title="Optimizing RSC Payloads">
99111
{defer(<OptimizingPayloads />, { name: "OptimizingPayloads" })}
100112
</Layout>
101113
),
102114
}),
103115
route({
104116
path: "/learn/lazy-server-components",
105117
component: (
106-
<Layout>
118+
<Layout title="Using lazy() in Server Components">
107119
{defer(<LazyServerComponents />, { name: "LazyServerComponents" })}
108120
</Layout>
109121
),
110122
}),
111123
route({
112124
path: "/learn/defer-and-activity",
113125
component: (
114-
<Layout>
126+
<Layout title="Prefetching with defer() and Activity">
115127
{defer(<DeferAndActivity />, { name: "DeferAndActivity" })}
116128
</Layout>
117129
),
118130
}),
119131
route({
120132
path: "/learn/file-system-routing",
121133
component: (
122-
<Layout>
134+
<Layout title="File-System Routing">
123135
{defer(<FileSystemRouting />, { name: "FileSystemRouting" })}
124136
</Layout>
125137
),
126138
}),
127139
route({
128140
path: "/advanced/multiple-entrypoints",
129141
component: (
130-
<Layout>
142+
<Layout title="Multiple Entrypoints (SSG)">
131143
{defer(<MultipleEntrypoints />, { name: "MultipleEntrypoints" })}
132144
</Layout>
133145
),
134146
}),
135147
route({
136148
path: "/advanced/ssr",
137-
component: <Layout>{defer(<SSR />, { name: "SSR" })}</Layout>,
149+
component: (
150+
<Layout title="Server-Side Rendering">
151+
{defer(<SSR />, { name: "SSR" })}
152+
</Layout>
153+
),
138154
}),
139155
route({
140156
path: "*",
141157
component: (
142-
<Layout>
158+
<Layout title="Not Found">
143159
<NotFound />
144160
</Layout>
145161
),

packages/docs/src/components/Layout/Layout.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,25 @@ type LayoutVariant = "home" | "docs";
1111
interface LayoutProps {
1212
children: React.ReactNode;
1313
variant?: LayoutVariant;
14+
title?: string;
1415
}
1516

1617
export const Layout: React.FC<LayoutProps> = ({
1718
children,
1819
variant = "docs",
20+
title,
1921
}) => {
2022
const layoutClass =
2123
variant === "home" ? styles.homeLayout : styles.docsLayout;
24+
const fullTitle = title
25+
? `${title} | FUNSTACK Static`
26+
: "FUNSTACK Static - docs";
2227

2328
return (
2429
<div className={`${styles.layout} ${layoutClass}`}>
30+
<title>{fullTitle}</title>
31+
<meta property="og:title" content={fullTitle} />
32+
<meta name="twitter:title" content={fullTitle} />
2533
<Header menuSlot={<MobileMenu />} />
2634
<div className={styles.main}>
2735
{variant === "docs" && <Sidebar />}

packages/docs/src/root.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ export default function Root({ children }: { children: React.ReactNode }) {
77
<head>
88
<meta charSet="UTF-8" />
99
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
10-
<title>FUNSTACK Static - docs</title>
1110
<meta
1211
name="description"
1312
content="FUNSTACK Static - A React framework without servers"
1413
/>
1514
{/* Open Graph / Facebook */}
1615
<meta property="og:type" content="website" />
17-
<meta property="og:title" content="FUNSTACK Static - docs" />
1816
<meta
1917
property="og:description"
2018
content="FUNSTACK Static - A React framework without servers"
@@ -25,7 +23,6 @@ export default function Root({ children }: { children: React.ReactNode }) {
2523
/>
2624
{/* Twitter */}
2725
<meta name="twitter:card" content="summary_large_image" />
28-
<meta name="twitter:title" content="FUNSTACK Static - docs" />
2926
<meta
3027
name="twitter:description"
3128
content="FUNSTACK Static - A React framework without servers"

0 commit comments

Comments
 (0)