aboutsummaryrefslogtreecommitdiff
path: root/src/utils/schemas/pageSchema.ts
blob: 606488b35c2fff6574e5d5716c5a97c329e43e86 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import type { WithContext, WebPage } from "schema-dts";

export type WebsiteSchemaParams = {
	readonly description: string;
	readonly page: string;
	readonly siteUrl: string;
	readonly title: string;
	readonly lang: string;
};

export default ({ siteUrl, page, title, description, lang }: WebsiteSchemaParams): WithContext<WebPage> => ({
	"@context": "https://schema.org",
	"@type": "WebPage",
	"@id": new URL(page, siteUrl).toString(),
	"url": new URL(page, siteUrl).toString(),
	"name": title,
	"description": description,
	"inLanguage": lang,
	"mainEntity": {
		"@type": "WebSite",
		"@id": new URL("/", siteUrl).toString(),
	},
});