mirror of
https://github.com/walkxcode/dashboard-icons.git
synced 2025-11-09 04:58:57 +01:00
Merge branch 'main' into feat/ph-capture-missing-icons
Signed-off-by: Thomas Camlong <thomas@ajnart.fr>
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
@@ -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} />
|
||||
}
|
||||
|
||||
@@ -156,6 +156,8 @@ export function IconSearch({ icons }: IconSearchProps) {
|
||||
[pathname, router, initialSort],
|
||||
)
|
||||
|
||||
|
||||
|
||||
const handleSearch = useCallback(
|
||||
(query: string) => {
|
||||
setSearchQuery(query)
|
||||
@@ -211,10 +213,7 @@ export function IconSearch({ icons }: IconSearchProps) {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (filteredIcons.length === 0 && searchQuery && searchQuery.length > 3) {
|
||||
console.log("no icons found", {
|
||||
query: searchQuery,
|
||||
})
|
||||
if (filteredIcons.length === 0) {
|
||||
posthog.capture("no icons found", {
|
||||
query: searchQuery,
|
||||
})
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user