Skip to content

Commit dac521c

Browse files
BramSuurdjeMickLeskhavardthom
authored
Fixing Front end issues related to image loading and SEO (#219)
* Update mariadb.json * Update vaultwarden.json * Update vaultwarden.json * Update keycloak.json * Update json/keycloak.json Co-authored-by: Håvard Gjøby Thom <[email protected]> * Update mariadb.json Co-authored-by: Håvard Gjøby Thom <[email protected]> * Add canonical link to layout for improved SEO and page indexing * Fix image source fallback for script logos to use a consistent relative path * Fix image source for script logos across components to consistently use the "/ProxmoxVE/logo.png" path * Update image source for script logos to use basePath for consistent paths across all components * Fix image source for script logos to ensure leading slash is consistent for all components' paths --------- Co-authored-by: CanbiZ <[email protected]> Co-authored-by: Håvard Gjøby Thom <[email protected]>
1 parent c162f51 commit dac521c

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

frontend/src/app/layout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export default function RootLayout({
6464
src={`https://${analytics.url}/script.js`}
6565
data-website-id={analytics.token}
6666
></script>
67+
<link rel="canonical" href={metadata.metadataBase.href} />
6768
<link rel="manifest" href="manifest.webmanifest" />
6869
<link rel="preconnect" href="https://api.github.com" />
6970
</head>

frontend/src/app/scripts/_components/ScriptAccordion.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { cn } from "@/lib/utils";
1212
import Image from "next/image";
1313
import Link from "next/link";
1414
import { useState } from "react";
15+
import { basePath } from "@/config/siteConfig";
1516

1617
export default function ScriptAccordion({
1718
items,
@@ -104,13 +105,13 @@ export default function ScriptAccordion({
104105
>
105106
<div className="flex items-center">
106107
<Image
107-
src={script.logo || "/logo.png"}
108+
src={script.logo || `/${basePath}/logo.png`}
108109
height={16}
109110
width={16}
110111
unoptimized
111112
onError={(e) =>
112113
((e.currentTarget as HTMLImageElement).src =
113-
"/logo.png")
114+
`/${basePath}/logo.png`)
114115
}
115116
alt={script.name}
116117
className="mr-1 w-4 h-4 rounded-full"

frontend/src/app/scripts/_components/ScriptInfoBlocks.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
CardHeader,
88
CardTitle,
99
} from "@/components/ui/card";
10-
import { mostPopularScripts } from "@/config/siteConfig";
10+
import { basePath, mostPopularScripts } from "@/config/siteConfig";
1111
import { extractDate } from "@/lib/time";
1212
import { Category, Script } from "@/lib/types";
1313
import { CalendarPlus } from "lucide-react";
@@ -92,11 +92,15 @@ export function LatestScripts({ items }: { items: Category[] }) {
9292
<CardTitle className="flex items-center gap-3">
9393
<div className="flex h-16 w-16 items-center justify-center rounded-lg bg-accent p-1">
9494
<Image
95-
src={script.logo || "/logo.png"}
95+
src={script.logo || `/${basePath}/logo.png`}
9696
unoptimized
9797
height={64}
9898
width={64}
9999
alt=""
100+
onError={(e) =>
101+
((e.currentTarget as HTMLImageElement).src =
102+
`/${basePath}/logo.png`)
103+
}
100104
className="h-11 w-11 object-contain"
101105
/>
102106
</div>
@@ -161,10 +165,14 @@ export function MostViewedScripts({ items }: { items: Category[] }) {
161165
<div className="flex max-h-16 min-h-16 min-w-16 max-w-16 items-center justify-center rounded-lg bg-accent p-1">
162166
<Image
163167
unoptimized
164-
src={script.logo || "/logo.png"}
168+
src={script.logo || `/${basePath}/logo.png`}
165169
height={64}
166170
width={64}
167171
alt=""
172+
onError={(e) =>
173+
((e.currentTarget as HTMLImageElement).src =
174+
`/${basePath}/logo.png`)
175+
}
168176
className="h-11 w-11 object-contain"
169177
/>
170178
</div>

frontend/src/app/scripts/_components/ScriptItem.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Description from "./ScriptItems/Description";
1414
import InstallCommand from "./ScriptItems/InstallCommand";
1515
import InterFaces from "./ScriptItems/InterFaces";
1616
import Tooltips from "./ScriptItems/Tooltips";
17+
import { basePath } from "@/config/siteConfig";
1718

1819
function ScriptItem({
1920
item,
@@ -40,10 +41,11 @@ function ScriptItem({
4041
<div className="flex">
4142
<Image
4243
className="h-32 w-32 rounded-lg bg-accent/60 object-contain p-3 shadow-md"
43-
src={item.logo || "/logo.png"}
44+
src={item.logo || `/${basePath}/logo.png`}
4445
width={400}
4546
onError={(e) =>
46-
((e.currentTarget as HTMLImageElement).src = "/logo.png")
47+
((e.currentTarget as HTMLImageElement).src =
48+
`/${basePath}/logo.png`)
4749
}
4850
height={400}
4951
alt={item.name}

frontend/src/components/CommandMenu.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import React from "react";
1515
import { Badge } from "./ui/badge";
1616
import { Button } from "./ui/button";
1717
import { DialogTitle } from "./ui/dialog";
18+
import { basePath } from "@/config/siteConfig";
1819

1920
export const formattedBadge = (type: string) => {
2021
switch (type) {
@@ -102,10 +103,10 @@ export default function CommandMenu() {
102103
>
103104
<div className="flex gap-2" onClick={() => setOpen(false)}>
104105
<Image
105-
src={script.logo || "/logo.png"}
106+
src={script.logo || `/${basePath}/logo.png`}
106107
onError={(e) =>
107108
((e.currentTarget as HTMLImageElement).src =
108-
"/logo.png")
109+
`/${basePath}/logo.png`)
109110
}
110111
unoptimized
111112
width={16}

0 commit comments

Comments
 (0)