fix: json-ld incorrect

This commit is contained in:
trafficlunar 2025-09-12 20:04:42 +01:00
parent d5fb8b191d
commit 2d5b09b2e2

View file

@ -2,6 +2,8 @@ import type { Metadata } from "next";
import Script from "next/script"; import Script from "next/script";
import { Lexend } from "next/font/google"; import { Lexend } from "next/font/google";
import { WebSite, WithContext } from "schema-dts";
import "./globals.css"; import "./globals.css";
import Providers from "./provider"; import Providers from "./provider";
@ -46,18 +48,38 @@ export default function RootLayout({
}: Readonly<{ }: Readonly<{
children: React.ReactNode; children: React.ReactNode;
}>) { }>) {
const jsonLd: WithContext<WebSite> = {
"@context": "https://schema.org",
"@type": "WebSite",
name: "TomodachiShare",
url: "https://tomodachishare.com",
description: "Discover and share Mii residents for your Tomodachi Life island!",
inLanguage: "en",
publisher: {
"@type": "Organization",
name: "TomodachiShare",
url: "https://tomodachishare.com",
logo: {
"@type": "ImageObject",
url: "https://tomodachishare.com/logo.png",
},
sameAs: ["https://trafficlunar.net", "https://twitter.com/trafficlunr", "https://bsky.app/profile/trafficlunar.net"],
},
potentialAction: {
"@type": "SearchAction",
target: "https://tomodachishare.com/?q={search_term_string}",
// @ts-expect-error whatever
"query-input": "required name=search_term_string",
},
};
return ( return (
<html lang="en"> <html lang="en">
<head> <head>
<script <script
type="application/ld+json" type="application/ld+json"
dangerouslySetInnerHTML={{ dangerouslySetInnerHTML={{
__html: JSON.stringify({ __html: JSON.stringify(jsonLd).replace(/</g, "\\u003c"),
"@context": "https://schema.org",
"@type": "WebSite",
name: "TomodachiShare",
url: process.env.NEXT_PUBLIC_BASE_URL,
}),
}} }}
/> />
</head> </head>