feat: page exclusive titles

This commit is contained in:
TrèsAbhi committed 2024-04-18 18:28:46 -05:00
1 parent e834d31d92
commit ce5c9f4afa
2 files changed
+11 -5

No files matched your search

+2 -1
View File
@@ -30,6 +30,7 @@ const robotoFlex = Roboto_Flex({
export default function RootLayout({ children }: RootLayoutProps) { export default function RootLayout({ children }: RootLayoutProps) {
const pathname = usePathname(); const pathname = usePathname();
const isEmbed = pathname.split('/')[1] === 'embeds'; const isEmbed = pathname.split('/')[1] === 'embeds';
const isRoot = pathname === '/';
const [showDevBuildAlert, setShowDevBuildAlert] = useState(false); const [showDevBuildAlert, setShowDevBuildAlert] = useState(false);
const isFullScreen = useFullScreen(); const isFullScreen = useFullScreen();
@@ -45,7 +46,7 @@ export default function RootLayout({ children }: RootLayoutProps) {
return ( return (
<html lang="en" className={robotoFlex.className}> <html lang="en" className={robotoFlex.className}>
<head> <head>
<title>Blitzkrieg</title> {isRoot && <title>Blitzkrieg</title>}
<meta <meta
name="description" name="description"
content="🎉 Tools for everything World of Tanks Blitz" content="🎉 Tools for everything World of Tanks Blitz"
+9 -4
View File
@@ -15,21 +15,26 @@ export default function ToolsLayout({ children }: ToolsLayoutProps) {
const pathname = usePathname(); const pathname = usePathname();
const pathSplit = pathname.split('/'); const pathSplit = pathname.split('/');
const toolId = pathSplit.at(2); const toolId = pathSplit.at(2);
const isToolRoot = pathname === `/tools/${toolId}`;
const tool = TOOLS.find((tool) => tool.id === toolId); const tool = TOOLS.find((tool) => tool.id === toolId);
return ( return (
<> <>
{tool && ( {tool && (
<>
{isToolRoot && (
<> <>
<title>{tool.title}</title> <title>{tool.title}</title>
{tool.pageDescription !== undefined && (
<meta name="description" content={tool.pageDescription} />
)}
<meta <meta
property="og:image" property="og:image"
content={`/assets/banners/${toolId}.webp`} content={`/assets/banners/${toolId}.webp`}
/> />
{tool.pageDescription !== undefined && (
<meta name="description" content={tool.pageDescription} />
)}
</>
)}
</> </>
)} )}