forge
Explore
Log in

Don't you dare go Hollow

hezarfen_landing

Clone
★ 0

0 watching0 forksTypeScript581.6 KiB94b1804Burak Boduroğlu2 months ago15 commits

Seo.tsx60 lines, 2.3 KiBHistoryRawDownload
1import { Link, Meta, Title } from "@solidjs/meta";
2import { useLocation } from "@solidjs/router";
3import JsonLd from "~/components/JsonLd";
4import { site } from "~/config";
5import { t } from "~/i18n";
6import { OG_IMAGE, pageGraph } from "~/lib/schema";
7
8/** Per-page title/description plus the Open Graph tags link previews need. */
9export default function Seo(props: {
10 title: string;
11 description: string;
12 /** Use the title as given, rather than appending the brand suffix. */
13 full?: boolean;
14 /** Short nav label for the home → page trail. Off for the landing page. */
15 breadcrumb?: string;
16 /** Extra schema.org nodes describing what the page lists. */
17 schema?: object[];
18}) {
19 const location = useLocation();
20
21 const title = () => (props.full ? props.title : `${props.title} — ${t.meta.titleSuffix}`);
22 const url = () => `${site.url}${location.pathname}`;
23
24 return (
25 <>
26 <Title>{title()}</Title>
27 <Meta name="description" content={props.description} />
28 <Meta property="og:type" content="website" />
29 <Meta property="og:site_name" content={site.legalName} />
30 <Meta property="og:title" content={title()} />
31 <Meta property="og:description" content={props.description} />
32 <Meta property="og:url" content={url()} />
33 <Meta property="og:locale" content="tr_TR" />
34 {/* The card is the brand lockup, so one image serves every page. Width
35 and height let a scraper lay the preview out before it has the file. */}
36 <Meta property="og:image" content={OG_IMAGE} />
37 <Meta property="og:image:type" content="image/png" />
38 <Meta property="og:image:width" content="1200" />
39 <Meta property="og:image:height" content="630" />
40 <Meta property="og:image:alt" content={site.legalName} />
41 <Meta name="twitter:card" content="summary_large_image" />
42 <Meta name="twitter:title" content={title()} />
43 <Meta name="twitter:description" content={props.description} />
44 <Meta name="twitter:image" content={OG_IMAGE} />
45 <Meta name="twitter:image:alt" content={site.legalName} />
46 <Link rel="canonical" href={url()} />
47
48 <JsonLd
49 data={pageGraph({
50 url: url(),
51 title: title(),
52 description: props.description,
53 t,
54 breadcrumb: props.breadcrumb,
55 extra: props.schema,
56 })}
57 />
58 </>
59 );
60}