Skip to content

Commit

Permalink
🔧 chore: Update metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
canisminor1990 committed May 13, 2024
1 parent e8b8b73 commit daecd37
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 41 deletions.
13 changes: 0 additions & 13 deletions src/app/(auth)/login/[[...login]]/PageTitle.tsx

This file was deleted.

21 changes: 14 additions & 7 deletions src/app/(auth)/login/[[...login]]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import { SignIn } from '@clerk/nextjs';

import PageTitle from './PageTitle';
import { metadataModule } from '@/server/metadata';
import { translation } from '@/server/translation';

export const generateMetadata = async () => {
const { t } = await translation('clerk');
return metadataModule.generate({
description: t('signIn.start.subtitle'),
title: t('signIn.start.title', { applicationName: 'LobeChat' }),
url: '/login',
});
};

const Page = () => {
return (
<>
<PageTitle />
<SignIn path="/login" />
</>
);
return <SignIn path="/login" />;
};

Page.displayName = 'Login';

export default Page;
13 changes: 0 additions & 13 deletions src/app/(auth)/signup/[[...signup]]/PageTitle.tsx

This file was deleted.

21 changes: 14 additions & 7 deletions src/app/(auth)/signup/[[...signup]]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import { SignUp } from '@clerk/nextjs';

import PageTitle from './PageTitle';
import { metadataModule } from '@/server/metadata';
import { translation } from '@/server/translation';

export const generateMetadata = async () => {
const { t } = await translation('clerk');
return metadataModule.generate({
description: t('signUp.start.subtitle'),
title: t('signUp.start.title'),
url: '/signup',
});
};

const Page = () => {
return (
<>
<PageTitle />
<SignUp path="/signup" />
</>
);
return <SignUp path="/signup" />;
};

Page.displayName = 'SignUp';

export default Page;
12 changes: 11 additions & 1 deletion src/server/translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,15 @@ export const translation = async (ns: NS) => {
const file = readFileSync(filepath, 'utf8');
const i18ns = JSON.parse(file);

return { t: (key: string) => get(i18ns, key) };
return {
t: (key: string, options: { [key: string]: string } = {}) => {
let content = get(i18ns, key);
if (options) {
Object.entries(options).forEach(([key, value]) => {
content = content.replace(`{{${key}}}`, value);
});
}
return content;
},
};
};

0 comments on commit daecd37

Please sign in to comment.