mirror of
https://github.com/walkxcode/dashboard-icons.git
synced 2025-06-28 07:20:21 +08:00
chore: format web
codebase
This commit is contained in:
parent
cfb5917a5d
commit
090f48c1c7
@ -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 }>;
|
||||
};
|
||||
|
||||
export async function generateMetadata(
|
||||
{ params, searchParams }: Props,
|
||||
parent: ResolvingMetadata,
|
||||
): Promise<Metadata> {
|
||||
const { icon } = await params;
|
||||
const iconsData = await getAllIcons();
|
||||
if (!iconsData[icon]) {
|
||||
notFound();
|
||||
params: Promise<{ icon: string }>
|
||||
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
|
||||
}
|
||||
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()}`,
|
||||
);
|
||||
export async function generateMetadata({ params, searchParams }: Props, parent: ResolvingMetadata): Promise<Metadata> {
|
||||
const { icon } = await params
|
||||
const iconsData = await getAllIcons()
|
||||
if (!iconsData[icon]) {
|
||||
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 iconImageUrl = `${BASE_URL}/png/${icon}.png`;
|
||||
const pageUrl = `${WEB_URL}/icons/${icon}`;
|
||||
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 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} />
|
||||
}
|
||||
|
@ -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",
|
||||
|
@ -58,11 +58,7 @@ export function Header() {
|
||||
<div className="flex items-center gap-2 md:gap-4">
|
||||
{/* Desktop search button */}
|
||||
<div className="hidden md:block">
|
||||
<Button
|
||||
variant="outline"
|
||||
className="gap-2 cursor-pointer transition-all duration-300"
|
||||
onClick={openCommandMenu}
|
||||
>
|
||||
<Button variant="outline" className="gap-2 cursor-pointer transition-all duration-300" onClick={openCommandMenu}>
|
||||
<Search className="h-4 w-4 transition-all duration-300" />
|
||||
<span>Find icons</span>
|
||||
<kbd className="pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border border-border/80 bg-muted/80 px-1.5 font-mono text-[10px] font-medium opacity-100">
|
||||
|
@ -216,7 +216,8 @@ export function HeroSection({ totalIcons, stars }: { totalIcons: number; stars:
|
||||
</h1>
|
||||
|
||||
<p className="text-sm sm:text-base md:text-xl text-muted-foreground leading-relaxed mb-8 font-light tracking-wide max-w-2xl mx-auto px-4 motion-preset-slide-down motion-duration-500">
|
||||
A collection of <NumberTicker value={totalIcons} startValue={1000} className="font-bold tracking-tighter text-muted-foreground" /> curated icons
|
||||
A collection of{" "}
|
||||
<NumberTicker value={totalIcons} startValue={1000} className="font-bold tracking-tighter text-muted-foreground" /> curated icons
|
||||
for services, applications and tools, designed specifically for dashboards and app directories.
|
||||
</p>
|
||||
<div className="flex flex-col gap-4 max-w-3xl mx-auto">
|
||||
|
@ -72,10 +72,7 @@ export function IconSubmissionForm() {
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
className="hidden md:inline-flex cursor-pointer transition-all duration-300"
|
||||
>
|
||||
<Button variant="outline" className="hidden md:inline-flex cursor-pointer transition-all duration-300">
|
||||
<PlusCircle className="h-4 w-4 transition-all duration-300" /> Contribute new icon
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
|
@ -1,16 +1,16 @@
|
||||
"use client";
|
||||
"use client"
|
||||
|
||||
import { useInView, useMotionValue, useSpring } from "motion/react";
|
||||
import { ComponentPropsWithoutRef, useEffect, useRef } from "react";
|
||||
import { useInView, useMotionValue, useSpring } from "motion/react"
|
||||
import { type ComponentPropsWithoutRef, useEffect, useRef } from "react"
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
interface NumberTickerProps extends ComponentPropsWithoutRef<"span"> {
|
||||
value: number;
|
||||
startValue?: number;
|
||||
direction?: "up" | "down";
|
||||
delay?: number;
|
||||
decimalPlaces?: number;
|
||||
value: number
|
||||
startValue?: number
|
||||
direction?: "up" | "down"
|
||||
delay?: number
|
||||
decimalPlaces?: number
|
||||
}
|
||||
|
||||
export function NumberTicker({
|
||||
@ -22,43 +22,36 @@ export function NumberTicker({
|
||||
decimalPlaces = 0,
|
||||
...props
|
||||
}: NumberTickerProps) {
|
||||
const ref = useRef<HTMLSpanElement>(null);
|
||||
const motionValue = useMotionValue(direction === "down" ? value : startValue);
|
||||
const ref = useRef<HTMLSpanElement>(null)
|
||||
const motionValue = useMotionValue(direction === "down" ? value : startValue)
|
||||
const springValue = useSpring(motionValue, {
|
||||
damping: 30,
|
||||
stiffness: 200,
|
||||
});
|
||||
const isInView = useInView(ref, { once: true, margin: "0px" });
|
||||
})
|
||||
const isInView = useInView(ref, { once: true, margin: "0px" })
|
||||
|
||||
useEffect(() => {
|
||||
if (isInView) {
|
||||
const timer = setTimeout(() => {
|
||||
motionValue.set(direction === "down" ? startValue : value);
|
||||
}, delay * 1000);
|
||||
return () => clearTimeout(timer);
|
||||
motionValue.set(direction === "down" ? startValue : value)
|
||||
}, delay * 1000)
|
||||
return () => clearTimeout(timer)
|
||||
}
|
||||
}, [motionValue, isInView, delay, value, direction, startValue]);
|
||||
}, [motionValue, isInView, delay, value, direction, startValue])
|
||||
|
||||
useEffect(
|
||||
() =>
|
||||
springValue.on("change", (latest) => {
|
||||
if (ref.current) {
|
||||
ref.current.textContent = Number(latest.toFixed(decimalPlaces)).toString();
|
||||
ref.current.textContent = Number(latest.toFixed(decimalPlaces)).toString()
|
||||
}
|
||||
}),
|
||||
[springValue, decimalPlaces],
|
||||
);
|
||||
)
|
||||
|
||||
return (
|
||||
<span
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"inline-block tabular-nums tracking-wider",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<span ref={ref} className={cn("inline-block tabular-nums tracking-wider", className)} {...props}>
|
||||
{startValue}
|
||||
</span>
|
||||
);
|
||||
)
|
||||
}
|
||||
|
@ -18,11 +18,7 @@ export function ThemeSwitcher() {
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
className=" transition-colors duration-200 group hover:ring-2 rounded-lg cursor-pointer"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
>
|
||||
<Button className=" transition-colors duration-200 group hover:ring-2 rounded-lg cursor-pointer" variant="ghost" size="icon">
|
||||
<Sun className="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0 group-hover:" />
|
||||
<Moon className="absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100 group-hover:" />
|
||||
<span className="sr-only">Toggle theme</span>
|
||||
|
Loading…
x
Reference in New Issue
Block a user