chore: format web codebase

This commit is contained in:
Thomas Camlong
2025-04-22 11:31:10 +02:00
parent cfb5917a5d
commit 090f48c1c7
9 changed files with 87 additions and 125 deletions

View File

@@ -1,7 +1,7 @@
import { getAllIcons } from "@/lib/api"
import { ImageResponse } from "next/og"
import { readFile } from "node:fs/promises"
import { join } from "node:path"
import { getAllIcons } from "@/lib/api"
import { ImageResponse } from "next/og"
export const dynamic = "force-static"

View File

@@ -1,49 +1,44 @@
import { IconDetails } from "@/components/icon-details";
import { BASE_URL, WEB_URL } from "@/constants";
import { getAllIcons, getAuthorData } from "@/lib/api";
import type { Metadata, ResolvingMetadata } from "next";
import { notFound } from "next/navigation";
import { IconDetails } from "@/components/icon-details"
import { BASE_URL, WEB_URL } from "@/constants"
import { getAllIcons, getAuthorData } from "@/lib/api"
import type { Metadata, ResolvingMetadata } from "next"
import { notFound } from "next/navigation"
export const dynamicParams = false;
export const dynamicParams = false
export async function generateStaticParams() {
const iconsData = await getAllIcons();
const iconsData = await getAllIcons()
return Object.keys(iconsData).map((icon) => ({
icon,
}));
}))
}
export const dynamic = "force-static";
export const dynamic = "force-static"
type Props = {
params: Promise<{ icon: string }>;
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
};
params: Promise<{ icon: string }>
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
}
export async function generateMetadata(
{ params, searchParams }: Props,
parent: ResolvingMetadata,
): Promise<Metadata> {
const { icon } = await params;
const iconsData = await getAllIcons();
export async function generateMetadata({ params, searchParams }: Props, parent: ResolvingMetadata): Promise<Metadata> {
const { icon } = await params
const iconsData = await getAllIcons()
if (!iconsData[icon]) {
notFound();
notFound()
}
const authorData = await getAuthorData(iconsData[icon].update.author.id);
const authorName = authorData.name || authorData.login;
const updateDate = new Date(iconsData[icon].update.timestamp);
const totalIcons = Object.keys(iconsData).length;
const authorData = await getAuthorData(iconsData[icon].update.author.id)
const authorName = authorData.name || authorData.login
const updateDate = new Date(iconsData[icon].update.timestamp)
const totalIcons = Object.keys(iconsData).length
console.debug(
`Generated metadata for ${icon} by ${authorName} (${authorData.html_url}) updated at ${updateDate.toLocaleString()}`,
);
console.debug(`Generated metadata for ${icon} by ${authorName} (${authorData.html_url}) updated at ${updateDate.toLocaleString()}`)
const iconImageUrl = `${BASE_URL}/png/${icon}.png`;
const pageUrl = `${WEB_URL}/icons/${icon}`;
const iconImageUrl = `${BASE_URL}/png/${icon}.png`
const pageUrl = `${WEB_URL}/icons/${icon}`
const formattedIconName = icon
.split("-")
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
.join(" ");
.join(" ")
return {
title: `${formattedIconName} Icon | Dashboard Icons`,
@@ -77,15 +72,7 @@ export async function generateMetadata(
publishedTime: updateDate.toISOString(),
modifiedTime: updateDate.toISOString(),
section: "Icons",
tags: [
formattedIconName,
"dashboard icon",
"service icon",
"application icon",
"tool icon",
"web dashboard",
"app directory",
],
tags: [formattedIconName, "dashboard icon", "service icon", "application icon", "tool icon", "web dashboard", "app directory"],
},
twitter: {
card: "summary_large_image",
@@ -101,27 +88,19 @@ export async function generateMetadata(
webp: `${BASE_URL}/webp/${icon}.webp`,
},
},
};
}
}
export default async function IconPage({
params,
}: { params: Promise<{ icon: string }> }) {
const { icon } = await params;
const iconsData = await getAllIcons();
const originalIconData = iconsData[icon];
export default async function IconPage({ params }: { params: Promise<{ icon: string }> }) {
const { icon } = await params
const iconsData = await getAllIcons()
const originalIconData = iconsData[icon]
if (!originalIconData) {
notFound();
notFound()
}
const authorData = await getAuthorData(originalIconData.update.author.id);
const authorData = await getAuthorData(originalIconData.update.author.id)
return (
<IconDetails
icon={icon}
iconData={originalIconData}
authorData={authorData}
/>
);
return <IconDetails icon={icon} iconData={originalIconData} authorData={authorData} />
}

View File

@@ -7,8 +7,8 @@ import type { Metadata, Viewport } from "next"
import { Inter } from "next/font/google"
import { Toaster } from "sonner"
import "./globals.css"
import { ThemeProvider } from "./theme-provider"
import { getDescription, websiteTitle } from "@/constants"
import { ThemeProvider } from "./theme-provider"
const inter = Inter({
variable: "--font-inter",