Skip to content

Commit cc4720d

Browse files
committed
Move extract publisher id to utils
1 parent d9c6155 commit cc4720d

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

app/[locale]/(user)/publishers/[publisherSlug]/page.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Metadata } from 'next';
22
import { graphql } from '@/gql';
33

44
import { GraphQL } from '@/lib/api';
5-
import { generatePageMetadata } from '@/lib/utils';
5+
import { extractPublisherId, generatePageMetadata } from '@/lib/utils';
66
import PublisherPageClient from './PublisherPageClient';
77

88
const userInfo = graphql(`
@@ -18,16 +18,6 @@ const userInfo = graphql(`
1818
}
1919
`);
2020

21-
const extractPublisherId = (publisherSlug: any) => {
22-
// If the param contains an underscore, split and take the last part
23-
if (publisherSlug.includes('_')) {
24-
return publisherSlug.split('_').pop();
25-
}
26-
27-
// Otherwise, return the param as is (it's already just the ID)
28-
return publisherSlug;
29-
};
30-
3121
export async function generateMetadata({
3222
params,
3323
}: {

lib/utils.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Metadata } from 'next';
2+
import { Metadata } from 'next';
23
import { twMerge, type ClassNameValue } from 'tailwind-merge';
34

45
type MetadataOptions = {
@@ -148,11 +149,23 @@ export function formatDateString(
148149
)
149150
.toISOString()
150151
.split('T')[0]
152+
date.toLocaleDateString('en-US', {
153+
year: 'numeric',
154+
month: 'numeric',
155+
// day: 'numeric',
156+
})
157+
)
158+
.toISOString()
159+
.split('T')[0]
151160
: date.toLocaleDateString('en-US', {
152161
month: 'long',
153162
// day: 'numeric',
154163
year: 'numeric',
155164
});
165+
month: 'long',
166+
// day: 'numeric',
167+
year: 'numeric',
168+
});
156169
}
157170

158171
export async function getWebsiteTitle(url: string): Promise<string | null> {
@@ -256,3 +269,12 @@ export const ENTITY_CONFIG: ENTITY_CONFIG_TYPE = {
256269
priority: '0.6',
257270
},
258271
};
272+
export const extractPublisherId = (publisherSlug: any) => {
273+
// If the param contains an underscore, split and take the last part
274+
if (publisherSlug.includes('_')) {
275+
return publisherSlug.split('_').pop();
276+
}
277+
278+
// Otherwise, return the param as is (it's already just the ID)
279+
return publisherSlug;
280+
};

0 commit comments

Comments
 (0)