|
1 | 1 | import { formatDate } from '@/lib/common'
|
2 | 2 | import { Avatar } from '@/components/Avatar'
|
3 | 3 | import { NextSeo } from 'next-seo'
|
| 4 | +import siteConfig from '../../config/siteConfig' |
4 | 5 |
|
5 | 6 | type Props = any
|
6 | 7 |
|
7 | 8 | export const BlogLayout: React.FC<Props> = ({ children, ...frontMatter }) => {
|
8 |
| - const { title, date, authors, description } = frontMatter |
| 9 | + const { title, date, authors, description, image } = frontMatter |
9 | 10 |
|
10 | 11 | return (
|
11 |
| - <article className="docs prose prose-a:text-primary dark:prose-a:text-primary-dark prose-strong:text-primary dark:prose-strong:text-primary-dark prose-code:text-primary dark:prose-code:text-primary-dark prose-headings:text-primary dark:prose-headings:text-primary-dark prose text-primary dark:text-primary-dark prose-headings:font-headings dark:prose-invert prose-a:break-words mx-auto p-6"> |
12 |
| - <header> |
13 |
| - <div className="mb-4 flex-col items-center"> |
14 |
| - {title && <h1 className="flex justify-center mb-0">{title}</h1>} |
15 |
| - {date && ( |
16 |
| - <p className="mt-2 text-sm text-zinc-400 dark:text-zinc-500 flex justify-left"> |
17 |
| - <time dateTime={date}>{formatDate(date)}</time> |
18 |
| - </p> |
19 |
| - )} |
20 |
| - {authors && ( |
21 |
| - <div className="flex flex-wrap not-prose items-center justify-left gap-4"> |
22 |
| - {authors.map(({ name, avatar, urlPath }) => ( |
23 |
| - <Avatar |
24 |
| - key={urlPath || name} |
25 |
| - name={name} |
26 |
| - img={avatar} |
27 |
| - href={urlPath ? `/${urlPath}` : undefined} |
28 |
| - /> |
29 |
| - ))} |
30 |
| - </div> |
31 |
| - )} |
32 |
| - </div> |
33 |
| - </header> |
34 |
| - <section>{children}</section> |
35 |
| - </article> |
| 12 | + <> |
| 13 | + <NextSeo |
| 14 | + title={title} |
| 15 | + description={description} |
| 16 | + openGraph={{ |
| 17 | + title, |
| 18 | + description, |
| 19 | + images: [ |
| 20 | + { |
| 21 | + url: image ? `https://www.portaljs.com` + image : siteConfig.nextSeo.openGraph.images[0].url, |
| 22 | + alt: title, |
| 23 | + }, |
| 24 | + ], |
| 25 | + type: 'article', |
| 26 | + }} |
| 27 | + twitter={{ |
| 28 | + cardType: 'summary_large_image', |
| 29 | + site: '@PortalJS_', |
| 30 | + }} |
| 31 | + /> |
| 32 | + <article className="docs prose prose-a:text-primary dark:prose-a:text-primary-dark prose-strong:text-primary dark:prose-strong:text-primary-dark prose-code:text-primary dark:prose-code:text-primary-dark prose-headings:text-primary dark:prose-headings:text-primary-dark prose text-primary dark:text-primary-dark prose-headings:font-headings dark:prose-invert prose-a:break-words mx-auto p-6"> |
| 33 | + <header> |
| 34 | + <div className="mb-4 flex-col items-center"> |
| 35 | + {title && <h1 className="flex justify-center mb-0">{title}</h1>} |
| 36 | + {date && ( |
| 37 | + <p className="mt-2 text-sm text-zinc-400 dark:text-zinc-500 flex justify-left"> |
| 38 | + <time dateTime={date}>{formatDate(date)}</time> |
| 39 | + </p> |
| 40 | + )} |
| 41 | + {authors && ( |
| 42 | + <div className="flex flex-wrap not-prose items-center justify-left gap-4"> |
| 43 | + {authors.map(({ name, avatar, urlPath }) => ( |
| 44 | + <Avatar |
| 45 | + key={urlPath || name} |
| 46 | + name={name} |
| 47 | + img={avatar} |
| 48 | + href={urlPath ? `/${urlPath}` : undefined} |
| 49 | + /> |
| 50 | + ))} |
| 51 | + </div> |
| 52 | + )} |
| 53 | + </div> |
| 54 | + </header> |
| 55 | + <section>{children}</section> |
| 56 | + </article> |
| 57 | + </> |
36 | 58 | )
|
37 | 59 | }
|
0 commit comments