11import { twMerge , type ClassNameValue } from 'tailwind-merge' ;
2+ import { Metadata } from 'next' ;
3+
4+ type MetadataOptions = {
5+ title ?: string ;
6+ url ?: string ;
7+ image ?: string ;
8+ description ?: string ;
9+ keywords ?: string [ ] ;
10+ openGraph ?: {
11+ type : 'website' | 'article' | 'dataset' ;
12+ locale : string ;
13+ url : string ;
14+ title : string ;
15+ description : string ;
16+ siteName ?: string ;
17+ image ?: string ;
18+ } ;
19+ } ;
20+
21+
22+ export function generatePageMetadata ( options : MetadataOptions = { } ) : Metadata {
23+ return {
24+ title : options . title ,
25+ description :
26+ options . description ,
27+ keywords : options . keywords ,
28+ openGraph : {
29+ type : 'website' ,
30+ locale : 'en_US' ,
31+ url : options . openGraph ?. url ,
32+ title : options . openGraph ?. title ,
33+ description : options . openGraph ?. description ,
34+ siteName : options . openGraph ?. siteName ,
35+ images : options . openGraph ?. image ,
36+ } ,
37+ twitter : {
38+ card : 'summary_large_image' ,
39+ title : options . openGraph ?. title ,
40+ description : options . openGraph ?. description ,
41+ images : options . openGraph ?. image ,
42+ creator : 'CivicDataLab' ,
43+ } ,
44+
45+ } ;
46+ }
47+
248
349export function cn ( ...inputs : ClassNameValue [ ] ) {
450 return twMerge ( inputs ) ;
@@ -89,19 +135,19 @@ export function formatDateString(
89135 // If hyphendated it would return date in this format - 2023-01-01 else in April 1, 2021
90136 return isHyphenated
91137 ? new Date (
92- date . toLocaleDateString ( 'en-US' , {
93- year : 'numeric' ,
94- month : 'numeric' ,
95- // day: 'numeric',
96- } )
97- )
98- . toISOString ( )
99- . split ( 'T' ) [ 0 ]
100- : date . toLocaleDateString ( 'en-US' , {
101- month : 'long' ,
102- // day: 'numeric',
138+ date . toLocaleDateString ( 'en-US' , {
103139 year : 'numeric' ,
104- } ) ;
140+ month : 'numeric' ,
141+ // day: 'numeric',
142+ } )
143+ )
144+ . toISOString ( )
145+ . split ( 'T' ) [ 0 ]
146+ : date . toLocaleDateString ( 'en-US' , {
147+ month : 'long' ,
148+ // day: 'numeric',
149+ year : 'numeric' ,
150+ } ) ;
105151}
106152
107153
@@ -120,3 +166,4 @@ export async function getWebsiteTitle(url: string): Promise<string | null> {
120166 return null ;
121167 }
122168}
169+
0 commit comments