Skip to content

Commit f617ade

Browse files
committed
feat: add meta tags to all of pages
1 parent dd4a91a commit f617ade

File tree

23 files changed

+184
-41
lines changed

23 files changed

+184
-41
lines changed

.env.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
NEXT_PUBLIC_BACKEND_URL=https://nextwoo.ir/graphql
2+
NEXT_PUBLIC_ORIGIN_URL=https://nextwoo.ir
23
NEXTAUTH_SECRET=jg3I65KxxWvmLWwbI8Zp9DbJsgyVJ+vHRAARmhF68+A=

public/assets/images/bale-black.svg

Lines changed: 0 additions & 5 deletions
This file was deleted.
324 Bytes
Loading
11.9 KB
Loading

public/assets/images/logo.jpg

3.55 KB
Loading
-2.27 KB
Binary file not shown.
-839 Bytes
Binary file not shown.
-4.59 KB
Binary file not shown.
-478 Bytes
Binary file not shown.

src/app/[locale]/(main)/(container)/blog/(WithFilters)/[id]/[[...slug]]/page.tsx

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import LocaleDate from '@/components/LocaleDate/LocaleDate';
22
import { getClient } from '@/graphql/clients/serverSideClient';
33
import { GET_POST } from '@/graphql/queries/blog';
44
import { GetPostQuery, GetPostQueryVariables } from '@/graphql/types/graphql';
5+
import { getRefinedMetaDescription } from '@/utils/text';
56
import { AccessTimeOutlined } from '@mui/icons-material';
67
import { Box, Stack, Typography } from '@mui/material';
8+
import { Metadata } from 'next';
79
import { notFound } from 'next/navigation';
810
import { FC } from 'react';
911
import PostCategories from './components/PostCategories';
10-
import { Metadata } from 'next';
11-
import { stripHtml } from '@/utils/text';
1212

1313
export type PageProps = {
1414
params: { id: string };
@@ -37,11 +37,38 @@ export async function generateMetadata(props: PageProps): Promise<Metadata> {
3737
return notFound();
3838
}
3939

40+
const title = post.title || '';
41+
const description = getRefinedMetaDescription(post.excerpt) || '';
42+
43+
const baseUrl = process.env.NEXT_PUBLIC_ORIGIN_URL!;
44+
const imageUrl = post.featuredImage?.node?.sourceUrl || '';
45+
const canonical = `/blog/${id}/${post.slug}`;
46+
4047
return {
41-
title: post.title,
42-
description: stripHtml(post.excerpt),
48+
title,
49+
description,
4350
alternates: {
44-
canonical: `/blog/${id}/${post.slug}`,
51+
canonical,
52+
},
53+
openGraph: {
54+
title,
55+
description,
56+
url: `${baseUrl}${canonical}`,
57+
siteName: title,
58+
images: [
59+
{
60+
url: imageUrl,
61+
width: 1200,
62+
height: 760,
63+
alt: title,
64+
},
65+
],
66+
},
67+
twitter: {
68+
card: 'summary_large_image',
69+
title,
70+
description,
71+
images: [imageUrl],
4572
},
4673
};
4774
}

0 commit comments

Comments
 (0)