chore: refactor metadata handling and remove unused files
- Delete obsolete `robots.ts` and `opengraph-image.tsx` files to streamline the codebase. - Update metadata generation across various pages to utilize `getBaseUrlWithLocale` for improved localization. - Ensure all pages have consistent canonical URLs for better SEO and accessibility. - Clean up imports and enhance the organization of metadata-related functions.
This commit is contained in:
parent
5d925b65c9
commit
2d8f70f09a
@ -7,7 +7,7 @@ import Pricing4 from '@/components/blocks/pricing/pricing-4';
|
||||
import StatsSection from '@/components/blocks/stats/stats';
|
||||
import Testimonials from '@/components/blocks/testimonials/testimonials';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { createTitle } from '@/lib/utils';
|
||||
import { getBaseUrlWithLocale } from '@/lib/urls/get-base-url';
|
||||
import { Metadata } from 'next';
|
||||
import { Locale } from 'next-intl';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
@ -20,12 +20,13 @@ export async function generateMetadata({
|
||||
}: {
|
||||
params: Promise<{ locale: Locale }>;
|
||||
}): Promise<Metadata | undefined> {
|
||||
const resolvedParams = await params;
|
||||
const { locale } = resolvedParams;
|
||||
const {locale} = await params;
|
||||
const t = await getTranslations({locale, namespace: 'Metadata'});
|
||||
|
||||
return constructMetadata({
|
||||
title: t('title'),
|
||||
description: t('description'),
|
||||
canonicalUrl: `${getBaseUrlWithLocale(locale)}/`,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { websiteConfig } from '@/config';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { getBaseUrlWithLocale } from '@/lib/urls/get-base-url';
|
||||
import { MailIcon } from 'lucide-react';
|
||||
import { Metadata } from 'next';
|
||||
import { Locale } from 'next-intl';
|
||||
@ -13,12 +14,14 @@ export async function generateMetadata({
|
||||
}: {
|
||||
params: Promise<{ locale: Locale }>;
|
||||
}): Promise<Metadata | undefined> {
|
||||
const resolvedParams = await params;
|
||||
const { locale } = resolvedParams;
|
||||
const {locale} = await params;
|
||||
const t = await getTranslations({locale, namespace: 'Metadata'});
|
||||
const pageTranslations = await getTranslations({locale, namespace: 'AboutPage'});
|
||||
|
||||
return constructMetadata({
|
||||
title: t('title'),
|
||||
description: t('description'),
|
||||
title: pageTranslations('title') + ' | ' + t('title'),
|
||||
description: pageTranslations('description'),
|
||||
canonicalUrl: `${getBaseUrlWithLocale(locale)}/about`,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ReleaseCard } from '@/components/release/release-card';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { getReleases } from '@/lib/release/get-releases';
|
||||
import { createTitle } from '@/lib/utils';
|
||||
import { getBaseUrlWithLocale } from '@/lib/urls/get-base-url';
|
||||
import type { NextPageProps } from '@/types/next-page-props';
|
||||
import type { Metadata } from 'next';
|
||||
import { Locale } from 'next-intl';
|
||||
@ -10,19 +10,19 @@ import { notFound } from 'next/navigation';
|
||||
|
||||
import '@/styles/mdx.css';
|
||||
|
||||
export async function generateMetadata(
|
||||
props: NextPageProps
|
||||
): Promise<Metadata> {
|
||||
const params = await props.params;
|
||||
if (!params) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const t = await getTranslations('ChangelogPage');
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ locale: Locale }>;
|
||||
}): Promise<Metadata | undefined> {
|
||||
const {locale} = await params;
|
||||
const t = await getTranslations({locale, namespace: 'Metadata'});
|
||||
const pageTranslations = await getTranslations({locale, namespace: 'ChangelogPage'});
|
||||
|
||||
return constructMetadata({
|
||||
title: createTitle(t('title')),
|
||||
description: t('subtitle'),
|
||||
title: pageTranslations('title') + ' | ' + t('title'),
|
||||
description: pageTranslations('description'),
|
||||
canonicalUrl: `${getBaseUrlWithLocale(locale)}/changelog`,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,16 +1,24 @@
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { createTitle } from '@/lib/utils';
|
||||
import { getBaseUrlWithLocale } from '@/lib/urls/get-base-url';
|
||||
import { Metadata } from 'next';
|
||||
import { Locale } from 'next-intl';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
import { ContactForm } from './contact-form';
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const t = await getTranslations('ContactPage');
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ locale: Locale }>;
|
||||
}): Promise<Metadata | undefined> {
|
||||
const {locale} = await params;
|
||||
const t = await getTranslations({locale, namespace: 'Metadata'});
|
||||
const pageTranslations = await getTranslations({locale, namespace: 'ContactPage'});
|
||||
|
||||
return constructMetadata({
|
||||
title: createTitle(t('title')),
|
||||
description: t('description'),
|
||||
title: pageTranslations('title') + ' | ' + t('title'),
|
||||
description: pageTranslations('description'),
|
||||
canonicalUrl: `${getBaseUrlWithLocale(locale)}/contact`,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,37 +1,37 @@
|
||||
import { CustomPage } from '@/components/page/custom-page';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { getCustomPage } from '@/lib/page/get-custom-page';
|
||||
import { getBaseUrl } from '@/lib/urls/get-base-url';
|
||||
import { getBaseUrlWithLocale } from '@/lib/urls/get-base-url';
|
||||
import type { NextPageProps } from '@/types/next-page-props';
|
||||
import type { Metadata } from 'next';
|
||||
import { Locale } from 'next-intl';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
import { notFound } from 'next/navigation';
|
||||
|
||||
import '@/styles/mdx.css';
|
||||
|
||||
export async function generateMetadata(
|
||||
props: NextPageProps
|
||||
): Promise<Metadata> {
|
||||
const params = await props.params;
|
||||
if (!params) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const locale = params.locale as string;
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ locale: Locale }>;
|
||||
}): Promise<Metadata | undefined> {
|
||||
const {locale} = await params;
|
||||
const page = await getCustomPage('cookie-policy', locale);
|
||||
|
||||
if (!page) {
|
||||
console.warn(
|
||||
`generateMetadata, page not found for cookie-policy, locale: ${locale}`
|
||||
);
|
||||
return {};
|
||||
}
|
||||
|
||||
return {
|
||||
title: page.title,
|
||||
const t = await getTranslations({locale, namespace: 'Metadata'});
|
||||
|
||||
return constructMetadata({
|
||||
title: page.title + ' | ' + t('title'),
|
||||
description: page.description,
|
||||
openGraph: {
|
||||
title: page.title,
|
||||
description: page.description,
|
||||
type: 'article',
|
||||
url: `${getBaseUrl()}/cookie-policy`,
|
||||
},
|
||||
};
|
||||
canonicalUrl: `${getBaseUrlWithLocale(locale)}/cookie-policy`,
|
||||
});
|
||||
}
|
||||
|
||||
export default async function CookiePolicyPage(props: NextPageProps) {
|
||||
|
@ -1,37 +1,37 @@
|
||||
import { CustomPage } from '@/components/page/custom-page';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { getCustomPage } from '@/lib/page/get-custom-page';
|
||||
import { getBaseUrl } from '@/lib/urls/get-base-url';
|
||||
import { getBaseUrlWithLocale } from '@/lib/urls/get-base-url';
|
||||
import type { NextPageProps } from '@/types/next-page-props';
|
||||
import type { Metadata } from 'next';
|
||||
import { Locale } from 'next-intl';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
import { notFound } from 'next/navigation';
|
||||
|
||||
import '@/styles/mdx.css';
|
||||
|
||||
export async function generateMetadata(
|
||||
props: NextPageProps
|
||||
): Promise<Metadata> {
|
||||
const params = await props.params;
|
||||
if (!params) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const locale = params.locale as string;
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ locale: Locale }>;
|
||||
}): Promise<Metadata | undefined> {
|
||||
const {locale} = await params;
|
||||
const page = await getCustomPage('privacy-policy', locale);
|
||||
|
||||
if (!page) {
|
||||
console.warn(
|
||||
`generateMetadata, page not found for privacy-policy, locale: ${locale}`
|
||||
);
|
||||
return {};
|
||||
}
|
||||
|
||||
return {
|
||||
title: page.title,
|
||||
const t = await getTranslations({locale, namespace: 'Metadata'});
|
||||
|
||||
return constructMetadata({
|
||||
title: page.title + ' | ' + t('title'),
|
||||
description: page.description,
|
||||
openGraph: {
|
||||
title: page.title,
|
||||
description: page.description,
|
||||
type: 'article',
|
||||
url: `${getBaseUrl()}/privacy-policy`,
|
||||
},
|
||||
};
|
||||
canonicalUrl: `${getBaseUrlWithLocale(locale)}/privacy-policy`,
|
||||
});
|
||||
}
|
||||
|
||||
export default async function PrivacyPolicyPage(props: NextPageProps) {
|
||||
|
@ -1,37 +1,37 @@
|
||||
import { CustomPage } from '@/components/page/custom-page';
|
||||
import { getCustomPage } from '@/lib/page/get-custom-page';
|
||||
import { getBaseUrl } from '@/lib/urls/get-base-url';
|
||||
import { getBaseUrlWithLocale } from '@/lib/urls/get-base-url';
|
||||
import type { NextPageProps } from '@/types/next-page-props';
|
||||
import type { Metadata } from 'next';
|
||||
import { notFound } from 'next/navigation';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { Locale } from 'next-intl';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
import '@/styles/mdx.css';
|
||||
|
||||
export async function generateMetadata(
|
||||
props: NextPageProps
|
||||
): Promise<Metadata> {
|
||||
const params = await props.params;
|
||||
if (!params) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const locale = params.locale as string;
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ locale: Locale }>;
|
||||
}): Promise<Metadata | undefined> {
|
||||
const {locale} = await params;
|
||||
const page = await getCustomPage('terms-of-service', locale);
|
||||
|
||||
if (!page) {
|
||||
console.warn(
|
||||
`generateMetadata, page not found for terms-of-service, locale: ${locale}`
|
||||
);
|
||||
return {};
|
||||
}
|
||||
|
||||
return {
|
||||
title: page.title,
|
||||
const t = await getTranslations({locale, namespace: 'Metadata'});
|
||||
|
||||
return constructMetadata({
|
||||
title: page.title + ' | ' + t('title'),
|
||||
description: page.description,
|
||||
openGraph: {
|
||||
title: page.title,
|
||||
description: page.description,
|
||||
type: 'article',
|
||||
url: `${getBaseUrl()}/terms-of-service`,
|
||||
},
|
||||
};
|
||||
canonicalUrl: `${getBaseUrlWithLocale(locale)}/terms-of-service`,
|
||||
});
|
||||
}
|
||||
|
||||
export default async function TermsOfServicePage(props: NextPageProps) {
|
||||
|
@ -1,22 +1,26 @@
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { createTitle } from '@/lib/utils';
|
||||
import { getBaseUrlWithLocale } from '@/lib/urls/get-base-url';
|
||||
import { Metadata } from 'next';
|
||||
import { Locale } from 'next-intl';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
import { WaitlistForm } from './waitlist-form';
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const t = await getTranslations('WaitlistPage');
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ locale: Locale }>;
|
||||
}): Promise<Metadata | undefined> {
|
||||
const {locale} = await params;
|
||||
const t = await getTranslations({locale, namespace: 'Metadata'});
|
||||
const pageTranslations = await getTranslations({locale, namespace: 'WaitlistPage'});
|
||||
return constructMetadata({
|
||||
title: createTitle(t('title')),
|
||||
description: t('description'),
|
||||
title: pageTranslations('title') + ' | ' + t('title'),
|
||||
description: pageTranslations('description'),
|
||||
canonicalUrl: `${getBaseUrlWithLocale(locale)}/waitlist`,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export default async function WaitlistPage() {
|
||||
const t = await getTranslations('WaitlistPage');
|
||||
|
||||
|
@ -2,24 +2,20 @@ import BlogGrid from '@/components/blog/blog-grid';
|
||||
import EmptyGrid from '@/components/shared/empty-grid';
|
||||
import CustomPagination from '@/components/shared/pagination';
|
||||
import { POSTS_PER_PAGE } from '@/constants';
|
||||
import { allPosts, allCategories } from 'content-collections';
|
||||
import { getWebsiteInfo } from '@/config';
|
||||
import { createTranslator } from '@/i18n/translator';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import type { Metadata } from 'next';
|
||||
import { getBaseUrlWithLocale } from '@/lib/urls/get-base-url';
|
||||
import { NextPageProps } from '@/types/next-page-props';
|
||||
import { getBaseUrl } from '@/lib/urls/get-base-url';
|
||||
import { allCategories, allPosts } from 'content-collections';
|
||||
import type { Metadata } from 'next';
|
||||
import { Locale } from 'next-intl';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
import { defaultMessages } from '@/i18n/messages';
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ slug: string; locale: Locale }>;
|
||||
}): Promise<Metadata | undefined> {
|
||||
const resolvedParams = await params;
|
||||
const { slug, locale } = resolvedParams;
|
||||
const { slug, locale } = await params;
|
||||
|
||||
// Find category with matching slug and locale
|
||||
const category = allCategories.find(
|
||||
@ -30,20 +26,21 @@ export async function generateMetadata({
|
||||
console.warn(
|
||||
`generateMetadata, category not found for slug: ${slug}, locale: ${locale}`
|
||||
);
|
||||
return;
|
||||
return {};
|
||||
}
|
||||
|
||||
const ogImageUrl = new URL(`${getBaseUrl()}/api/og`);
|
||||
ogImageUrl.searchParams.append('title', category.name);
|
||||
ogImageUrl.searchParams.append('description', category.description || '');
|
||||
ogImageUrl.searchParams.append('type', 'Blog Category');
|
||||
const t = await getTranslations({locale, namespace: 'Metadata'});
|
||||
|
||||
// TODO: add locale
|
||||
// TODO: add og image
|
||||
// const ogImageUrl = new URL(`${getBaseUrl()}/api/og`);
|
||||
// ogImageUrl.searchParams.append('title', category.name);
|
||||
// ogImageUrl.searchParams.append('description', category.description || '');
|
||||
// ogImageUrl.searchParams.append('type', 'Blog Category');
|
||||
|
||||
return constructMetadata({
|
||||
title: `${category.name} | ${defaultMessages.Site.title}`,
|
||||
title: `${category.name} | ${t('title')}`,
|
||||
description: category.description,
|
||||
canonicalUrl: `${getBaseUrl()}/blog/category/${slug}`,
|
||||
canonicalUrl: `${getBaseUrlWithLocale(locale)}/blog/category/${slug}`,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,20 +1,27 @@
|
||||
import { allPosts } from 'content-collections';
|
||||
import { Metadata } from 'next';
|
||||
import BlogGrid from '@/components/blog/blog-grid';
|
||||
import EmptyGrid from '@/components/shared/empty-grid';
|
||||
import CustomPagination from '@/components/shared/pagination';
|
||||
import { POSTS_PER_PAGE } from '@/constants';
|
||||
import { NextPageProps } from '@/types/next-page-props';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { createTitle } from '@/lib/utils';
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const t = await getTranslations('BlogPage');
|
||||
import { getBaseUrlWithLocale } from '@/lib/urls/get-base-url';
|
||||
import { NextPageProps } from '@/types/next-page-props';
|
||||
import { allPosts } from 'content-collections';
|
||||
import { Metadata } from 'next';
|
||||
import { Locale } from 'next-intl';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ locale: Locale }>;
|
||||
}): Promise<Metadata | undefined> {
|
||||
const {locale} = await params;
|
||||
const t = await getTranslations({locale, namespace: 'Metadata'});
|
||||
const pageTranslations = await getTranslations({locale, namespace: 'BlogPage'});
|
||||
return constructMetadata({
|
||||
title: createTitle(t('title')),
|
||||
description: t('description'),
|
||||
title: pageTranslations('title') + ' | ' + t('title'),
|
||||
description: pageTranslations('description'),
|
||||
canonicalUrl: `${getBaseUrlWithLocale(locale)}/blog`,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ import { BlogToc } from '@/components/blog/blog-toc';
|
||||
import { Mdx } from '@/components/shared/mdx-component';
|
||||
import { LocaleLink } from '@/i18n/navigation';
|
||||
import { getTableOfContents } from '@/lib/blog/toc';
|
||||
import { getBaseUrl } from '@/lib/urls/get-base-url';
|
||||
import { getBaseUrlWithLocale } from '@/lib/urls/get-base-url';
|
||||
import { estimateReadingTime, getLocaleDate } from '@/lib/utils';
|
||||
import type { NextPageProps } from '@/types/next-page-props';
|
||||
import { allPosts } from 'content-collections';
|
||||
@ -13,9 +13,9 @@ import { getTranslations } from 'next-intl/server';
|
||||
import Image from 'next/image';
|
||||
import { notFound } from 'next/navigation';
|
||||
|
||||
import '@/styles/mdx.css';
|
||||
import { defaultMessages } from '@/i18n/messages';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import '@/styles/mdx.css';
|
||||
import { Locale } from 'next-intl';
|
||||
|
||||
/**
|
||||
* Gets the blog post from the params
|
||||
@ -64,20 +64,30 @@ async function getBlogPostFromParams(props: NextPageProps) {
|
||||
return post;
|
||||
}
|
||||
|
||||
export async function generateMetadata(
|
||||
props: NextPageProps
|
||||
): Promise<Metadata> {
|
||||
const post = await getBlogPostFromParams(props);
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ slug: string; locale: Locale }>;
|
||||
}): Promise<Metadata | undefined> {
|
||||
const {slug, locale} = await params;
|
||||
|
||||
const post = await getBlogPostFromParams({
|
||||
params: Promise.resolve({ slug, locale }),
|
||||
searchParams: Promise.resolve({})
|
||||
});
|
||||
if (!post) {
|
||||
console.warn(
|
||||
`generateMetadata, post not found for slug: ${slug}, locale: ${locale}`
|
||||
);
|
||||
return {};
|
||||
}
|
||||
|
||||
// TODO: add image and locale
|
||||
const t = await getTranslations({locale, namespace: 'Metadata'});
|
||||
|
||||
return constructMetadata({
|
||||
title: `${post.title} | ${defaultMessages.Site.title}`,
|
||||
title: `${post.title} | ${t('title')}`,
|
||||
description: post.description,
|
||||
canonicalUrl: `${getBaseUrl()}${post.slug}`,
|
||||
canonicalUrl: `${getBaseUrlWithLocale(locale)}${post.slug}`,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -3,17 +3,23 @@ import Pricing4 from '@/components/blocks/pricing/pricing-4';
|
||||
import Pricing5 from '@/components/blocks/pricing/pricing-5';
|
||||
import PricingComparator from '@/components/pricing-comparator';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { createTitle } from '@/lib/utils';
|
||||
import { getBaseUrlWithLocale } from '@/lib/urls/get-base-url';
|
||||
import { Metadata } from 'next';
|
||||
import { Locale } from 'next-intl';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const t = await getTranslations('PricingPage');
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ locale: Locale }>;
|
||||
}): Promise<Metadata | undefined> {
|
||||
const {locale} = await params;
|
||||
const t = await getTranslations({locale, namespace: 'Metadata'});
|
||||
const pageTranslations = await getTranslations({locale, namespace: 'PricingPage'});
|
||||
return constructMetadata({
|
||||
title: createTitle(t('title')),
|
||||
description: t('description'),
|
||||
title: pageTranslations('title') + ' | ' + t('title'),
|
||||
description: pageTranslations('description'),
|
||||
canonicalUrl: `${getBaseUrlWithLocale(locale)}/pricing`,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,16 +1,26 @@
|
||||
import { ErrorCard } from '@/components/auth/error-card';
|
||||
import { getBaseUrl } from '@/lib/urls/get-base-url';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { Routes } from '@/routes';
|
||||
import { getBaseUrlWithLocale } from '@/lib/urls/get-base-url';
|
||||
import { Metadata } from 'next';
|
||||
import { Locale } from 'next-intl';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
export const metadata = constructMetadata({
|
||||
title: 'Auth Error',
|
||||
description: 'Auth Error',
|
||||
canonicalUrl: `${getBaseUrl()}${Routes.AuthError}`,
|
||||
});
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ locale: Locale }>;
|
||||
}): Promise<Metadata | undefined> {
|
||||
const {locale} = await params;
|
||||
const t = await getTranslations({locale, namespace: 'Metadata'});
|
||||
const pageTranslations = await getTranslations({locale, namespace: 'AuthPage.error'});
|
||||
|
||||
return constructMetadata({
|
||||
title: pageTranslations('title') + ' | ' + t('title'),
|
||||
description: t('description'),
|
||||
canonicalUrl: `${getBaseUrlWithLocale(locale)}/auth/error`,
|
||||
});
|
||||
}
|
||||
|
||||
const AuthErrorPage = () => {
|
||||
export default async function AuthErrorPage() {
|
||||
return <ErrorCard />;
|
||||
};
|
||||
|
||||
export default AuthErrorPage;
|
||||
}
|
||||
|
@ -1,16 +1,26 @@
|
||||
import { ForgotPasswordForm } from '@/components/auth/forgot-password-form';
|
||||
import { getBaseUrl } from '@/lib/urls/get-base-url';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { Routes } from '@/routes';
|
||||
import { getBaseUrlWithLocale } from '@/lib/urls/get-base-url';
|
||||
import { Metadata } from 'next';
|
||||
import { Locale } from 'next-intl';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
export const metadata = constructMetadata({
|
||||
title: 'Forgot Password',
|
||||
description: 'Forgot your password? Reset it.',
|
||||
canonicalUrl: `${getBaseUrl()}${Routes.ForgotPassword}`,
|
||||
});
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ locale: Locale }>;
|
||||
}): Promise<Metadata | undefined> {
|
||||
const {locale} = await params;
|
||||
const t = await getTranslations({locale, namespace: 'Metadata'});
|
||||
const pageTranslations = await getTranslations({locale, namespace: 'AuthPage.forgotPassword'});
|
||||
|
||||
return constructMetadata({
|
||||
title: pageTranslations('title') + ' | ' + t('title'),
|
||||
description: t('description'),
|
||||
canonicalUrl: `${getBaseUrlWithLocale(locale)}/auth/forgot-password`,
|
||||
});
|
||||
}
|
||||
|
||||
const ForgotPasswordPage = () => {
|
||||
export default async function ForgotPasswordPage() {
|
||||
return <ForgotPasswordForm />;
|
||||
};
|
||||
|
||||
export default ForgotPasswordPage;
|
||||
}
|
||||
|
@ -1,18 +1,30 @@
|
||||
import { LoginForm } from '@/components/auth/login-form';
|
||||
import { LocaleLink } from '@/i18n/navigation';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { getBaseUrl } from '@/lib/urls/get-base-url';
|
||||
import { getBaseUrlWithLocale } from '@/lib/urls/get-base-url';
|
||||
import { Routes } from '@/routes';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { Metadata } from 'next';
|
||||
import { Locale, useTranslations } from 'next-intl';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
export const metadata = constructMetadata({
|
||||
title: 'Login',
|
||||
description: 'Login to your account',
|
||||
canonicalUrl: `${getBaseUrl()}${Routes.Login}`,
|
||||
});
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ locale: Locale }>;
|
||||
}): Promise<Metadata | undefined> {
|
||||
const {locale} = await params;
|
||||
const t = await getTranslations({locale, namespace: 'Metadata'});
|
||||
const pageTranslations = await getTranslations({locale, namespace: 'AuthPage.login'});
|
||||
|
||||
return constructMetadata({
|
||||
title: pageTranslations('title') + ' | ' + t('title'),
|
||||
description: t('description'),
|
||||
canonicalUrl: `${getBaseUrlWithLocale(locale)}/auth/login`,
|
||||
});
|
||||
}
|
||||
|
||||
const LoginPage = () => {
|
||||
const t = useTranslations('AuthPage.login');
|
||||
export default async function LoginPage() {
|
||||
const t = await getTranslations('AuthPage.login');
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
@ -36,5 +48,3 @@ const LoginPage = () => {
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default LoginPage;
|
||||
|
@ -1,16 +1,26 @@
|
||||
import { RegisterForm } from '@/components/auth/register-form';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { getBaseUrl } from '@/lib/urls/get-base-url';
|
||||
import { Routes } from '@/routes';
|
||||
import { getBaseUrlWithLocale } from '@/lib/urls/get-base-url';
|
||||
import { Metadata } from 'next';
|
||||
import { Locale } from 'next-intl';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
export const metadata = constructMetadata({
|
||||
title: 'Register',
|
||||
description: 'Create an account to get started',
|
||||
canonicalUrl: `${getBaseUrl()}${Routes.Register}`,
|
||||
});
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ locale: Locale }>;
|
||||
}): Promise<Metadata | undefined> {
|
||||
const {locale} = await params;
|
||||
const t = await getTranslations({locale, namespace: 'Metadata'});
|
||||
const pageTranslations = await getTranslations({locale, namespace: 'AuthPage.register'});
|
||||
|
||||
return constructMetadata({
|
||||
title: pageTranslations('title') + ' | ' + t('title'),
|
||||
description: t('description'),
|
||||
canonicalUrl: `${getBaseUrlWithLocale(locale)}/auth/register`,
|
||||
});
|
||||
}
|
||||
|
||||
const RegisterPage = () => {
|
||||
export default async function RegisterPage() {
|
||||
return <RegisterForm />;
|
||||
};
|
||||
|
||||
export default RegisterPage;
|
||||
}
|
||||
|
@ -1,15 +1,26 @@
|
||||
import { ResetPasswordForm } from '@/components/auth/reset-password-form';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { getBaseUrl } from '@/lib/urls/get-base-url';
|
||||
import { getBaseUrlWithLocale } from '@/lib/urls/get-base-url';
|
||||
import { Metadata } from 'next';
|
||||
import { Locale } from 'next-intl';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
export const metadata = constructMetadata({
|
||||
title: 'Reset Password',
|
||||
description: 'Set a new password',
|
||||
canonicalUrl: `${getBaseUrl()}/auth/reset-password`,
|
||||
});
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ locale: Locale }>;
|
||||
}): Promise<Metadata | undefined> {
|
||||
const {locale} = await params;
|
||||
const t = await getTranslations({locale, namespace: 'Metadata'});
|
||||
const pageTranslations = await getTranslations({locale, namespace: 'AuthPage.resetPassword'});
|
||||
|
||||
return constructMetadata({
|
||||
title: pageTranslations('title') + ' | ' + t('title'),
|
||||
description: t('description'),
|
||||
canonicalUrl: `${getBaseUrlWithLocale(locale)}/auth/reset-password`,
|
||||
});
|
||||
}
|
||||
|
||||
const ResetPasswordPage = () => {
|
||||
export default async function ResetPasswordPage() {
|
||||
return <ResetPasswordForm />;
|
||||
};
|
||||
|
||||
export default ResetPasswordPage;
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
import { ImageResponse } from 'next/og';
|
||||
|
||||
/**
|
||||
* https://next-intl.dev/docs/environments/actions-metadata-route-handlers#open-graph-images
|
||||
*/
|
||||
export default async function OpenGraphImage({params}) {
|
||||
const {locale} = await params;
|
||||
const t = await getTranslations({locale, namespace: 'OpenGraphImage'});
|
||||
return new ImageResponse(<div style={{fontSize: 128}}>{t('title')}</div>);
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
import { getBaseUrl } from '@/lib/urls/get-base-url';
|
||||
import type { MetadataRoute } from 'next';
|
||||
|
||||
/**
|
||||
* https://nextjs.org/docs/app/api-reference/file-conventions/metadata/robots
|
||||
*/
|
||||
export default function robots(): MetadataRoute.Robots {
|
||||
return {
|
||||
rules: {
|
||||
userAgent: '*',
|
||||
allow: '/',
|
||||
},
|
||||
sitemap: `${getBaseUrl()}/sitemap.xml`,
|
||||
};
|
||||
}
|
@ -34,7 +34,7 @@ export function constructMetadata({
|
||||
openGraph: {
|
||||
type: 'website',
|
||||
locale: 'en_US', // TODO: use locale
|
||||
url: getBaseUrl(),
|
||||
url: canonicalUrl,
|
||||
title,
|
||||
description,
|
||||
siteName: title,
|
||||
|
@ -1,17 +1,18 @@
|
||||
// import { DEFAULT_LOCALE } from '@/lib/i18n/locale';
|
||||
import { routing } from "@/i18n/routing";
|
||||
|
||||
const baseUrl =
|
||||
process.env.NEXT_PUBLIC_BASE_URL ??
|
||||
`http://localhost:${process.env.PORT ?? 3000}`;
|
||||
|
||||
// TODO: fix all the places that use this function
|
||||
export function getBaseUrl(): string {
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
// export function shouldAppendLocale(locale?: string | null): boolean {
|
||||
// return !!locale && locale !== DEFAULT_LOCALE && locale !== 'default';
|
||||
// }
|
||||
export function shouldAppendLocale(locale?: string | null): boolean {
|
||||
return !!locale && locale !== routing.defaultLocale && locale !== 'default';
|
||||
}
|
||||
|
||||
// export function getBaseUrl(locale?: string | null): string {
|
||||
// return shouldAppendLocale(locale) ? `${baseUrl}/${locale}` : baseUrl;
|
||||
// }
|
||||
export function getBaseUrlWithLocale(locale?: string | null): string {
|
||||
return shouldAppendLocale(locale) ? `${baseUrl}/${locale}` : baseUrl;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user