-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathutils.ts
86 lines (82 loc) · 1.84 KB
/
utils.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { type ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"
import { tailwindColors } from "@/registry/colors";
import { siteConfig } from "@/config/site";
import { Metadata } from "next";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
export function absoluteUrl(path: string) {
return `${process.env.NEXT_PUBLIC_APP_URL}${path}`
}
export function getColorScaleValue(colorName: string, scale: number) {
if (tailwindColors[colorName]) {
const colorScale = tailwindColors[colorName].find(c => c.scale === scale);
if (colorScale) {
return colorScale.hex;
} else {
return `Scale ${scale} not found for color ${colorName}`;
}
} else {
return `Color ${colorName} not found`;
}
}
export function constructMetadata({
title = siteConfig.name,
description = siteConfig.description,
image = siteConfig.ogImage,
icons = "/favicon.ico",
noIndex = false,
}: {
title?: string;
description?: string;
image?: string;
icons?: string;
noIndex?: boolean;
} = {}): Metadata {
return {
title,
description,
keywords: [
"Next.js",
"React",
"Prisma",
"Neon",
"Auth.js",
"shadcn ui",
"Resend",
"React Email",
"Stripe",
],
authors: [
{
name: "mickasmt",
},
],
creator: "mickasmt",
openGraph: {
type: "website",
locale: "en_US",
url: siteConfig.url,
title,
description,
siteName: title,
},
twitter: {
card: "summary_large_image",
title,
description,
images: [image],
creator: "@miickasmt",
},
icons,
metadataBase: new URL(siteConfig.url),
manifest: `${siteConfig.url}/site.webmanifest`,
...(noIndex && {
robots: {
index: false,
follow: false,
},
}),
};
}