upstream #1
@ -178,6 +178,7 @@ summary (optional)
|
|||||||
images (optional, if none provided defaults to socialBanner in siteMetadata config)
|
images (optional, if none provided defaults to socialBanner in siteMetadata config)
|
||||||
authors (optional list which should correspond to the file names in `data/authors`. Uses `default` if none is specified)
|
authors (optional list which should correspond to the file names in `data/authors`. Uses `default` if none is specified)
|
||||||
layout (optional list which should correspond to the file names in `data/layouts`)
|
layout (optional list which should correspond to the file names in `data/layouts`)
|
||||||
|
canonicalUrl (optional, canonical url for the post for SEO)
|
||||||
```
|
```
|
||||||
|
|
||||||
Here's an example of a post's frontmatter:
|
Here's an example of a post's frontmatter:
|
||||||
@ -193,6 +194,7 @@ summary: 'Looking for a performant, out of the box template, with all the best i
|
|||||||
images: ['/static/images/canada/mountains.jpg', '/static/images/canada/toronto.jpg']
|
images: ['/static/images/canada/mountains.jpg', '/static/images/canada/toronto.jpg']
|
||||||
authors: ['default', 'sparrowhawk']
|
authors: ['default', 'sparrowhawk']
|
||||||
layout: PostLayout
|
layout: PostLayout
|
||||||
|
canonicalUrl: https://tailwind-nextjs-starter-blog.vercel.app/blog/introducing-tailwind-nextjs-starter-blog
|
||||||
---
|
---
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import Head from 'next/head'
|
|||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import siteMetadata from '@/data/siteMetadata'
|
import siteMetadata from '@/data/siteMetadata'
|
||||||
|
|
||||||
const CommonSEO = ({ title, description, ogType, ogImage, twImage }) => {
|
const CommonSEO = ({ title, description, ogType, ogImage, twImage, canonicalUrl }) => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
return (
|
return (
|
||||||
<Head>
|
<Head>
|
||||||
@ -24,6 +24,10 @@ const CommonSEO = ({ title, description, ogType, ogImage, twImage }) => {
|
|||||||
<meta name="twitter:title" content={title} />
|
<meta name="twitter:title" content={title} />
|
||||||
<meta name="twitter:description" content={description} />
|
<meta name="twitter:description" content={description} />
|
||||||
<meta name="twitter:image" content={twImage} />
|
<meta name="twitter:image" content={twImage} />
|
||||||
|
<link
|
||||||
|
rel="canonical"
|
||||||
|
href={canonicalUrl ? canonicalUrl : `${siteMetadata.siteUrl}${router.asPath}`}
|
||||||
|
/>
|
||||||
</Head>
|
</Head>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -67,7 +71,16 @@ export const TagSEO = ({ title, description }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const BlogSEO = ({ authorDetails, title, summary, date, lastmod, url, images = [] }) => {
|
export const BlogSEO = ({
|
||||||
|
authorDetails,
|
||||||
|
title,
|
||||||
|
summary,
|
||||||
|
date,
|
||||||
|
lastmod,
|
||||||
|
url,
|
||||||
|
images = [],
|
||||||
|
canonicalUrl,
|
||||||
|
}) => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const publishedAt = new Date(date).toISOString()
|
const publishedAt = new Date(date).toISOString()
|
||||||
const modifiedAt = new Date(lastmod || date).toISOString()
|
const modifiedAt = new Date(lastmod || date).toISOString()
|
||||||
@ -133,11 +146,11 @@ export const BlogSEO = ({ authorDetails, title, summary, date, lastmod, url, ima
|
|||||||
ogType="article"
|
ogType="article"
|
||||||
ogImage={featuredImages}
|
ogImage={featuredImages}
|
||||||
twImage={twImageUrl}
|
twImage={twImageUrl}
|
||||||
|
canonicalUrl={canonicalUrl}
|
||||||
/>
|
/>
|
||||||
<Head>
|
<Head>
|
||||||
{date && <meta property="article:published_time" content={publishedAt} />}
|
{date && <meta property="article:published_time" content={publishedAt} />}
|
||||||
{lastmod && <meta property="article:modified_time" content={modifiedAt} />}
|
{lastmod && <meta property="article:modified_time" content={modifiedAt} />}
|
||||||
<link rel="canonical" href={`${siteMetadata.siteUrl}${router.asPath}`} />
|
|
||||||
<script
|
<script
|
||||||
type="application/ld+json"
|
type="application/ld+json"
|
||||||
dangerouslySetInnerHTML={{
|
dangerouslySetInnerHTML={{
|
||||||
|
@ -149,6 +149,7 @@ summary (optional)
|
|||||||
images (optional, if none provided defaults to socialBanner in siteMetadata config)
|
images (optional, if none provided defaults to socialBanner in siteMetadata config)
|
||||||
authors (optional list which should correspond to the file names in `data/authors`. Uses `default` if none is specified)
|
authors (optional list which should correspond to the file names in `data/authors`. Uses `default` if none is specified)
|
||||||
layout (optional list which should correspond to the file names in `data/layouts`)
|
layout (optional list which should correspond to the file names in `data/layouts`)
|
||||||
|
canonicalUrl (optional, canonical url for the post for SEO)
|
||||||
```
|
```
|
||||||
|
|
||||||
Here's an example of a post's frontmatter:
|
Here's an example of a post's frontmatter:
|
||||||
@ -164,6 +165,7 @@ summary: 'Looking for a performant, out of the box template, with all the best i
|
|||||||
images: ['/static/images/canada/mountains.jpg', '/static/images/canada/toronto.jpg']
|
images: ['/static/images/canada/mountains.jpg', '/static/images/canada/toronto.jpg']
|
||||||
authors: ['default', 'sparrowhawk']
|
authors: ['default', 'sparrowhawk']
|
||||||
layout: PostLayout
|
layout: PostLayout
|
||||||
|
canonicalUrl: https://tailwind-nextjs-starter-blog.vercel.app/blog/introducing-tailwind-nextjs-starter-blog
|
||||||
---
|
---
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ draft: false
|
|||||||
summary: 'An overview of the new features released in v1 - code block copy, multiple authors, frontmatter layout and more'
|
summary: 'An overview of the new features released in v1 - code block copy, multiple authors, frontmatter layout and more'
|
||||||
layout: PostSimple
|
layout: PostSimple
|
||||||
bibliography: references-data.bib
|
bibliography: references-data.bib
|
||||||
|
canonicalUrl: https://tailwind-nextjs-starter-blog.vercel.app/blog/new-features-in-v1/
|
||||||
---
|
---
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -6,7 +6,7 @@
|
|||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "tailwind-nextjs-starter-blog",
|
"name": "tailwind-nextjs-starter-blog",
|
||||||
"version": "1.4.3",
|
"version": "1.5.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fontsource/inter": "4.5.2",
|
"@fontsource/inter": "4.5.2",
|
||||||
"@mailchimp/mailchimp_marketing": "^3.0.58",
|
"@mailchimp/mailchimp_marketing": "^3.0.58",
|
||||||
|
@ -40,6 +40,7 @@ const genFrontMatter = (answers) => {
|
|||||||
summary: ${answers.summary ? answers.summary : ' '}
|
summary: ${answers.summary ? answers.summary : ' '}
|
||||||
images: []
|
images: []
|
||||||
layout: ${answers.layout}
|
layout: ${answers.layout}
|
||||||
|
canonicalUrl: ${answers.canonicalUrl}
|
||||||
`
|
`
|
||||||
|
|
||||||
if (answers.authors.length > 0) {
|
if (answers.authors.length > 0) {
|
||||||
@ -92,6 +93,11 @@ inquirer
|
|||||||
type: 'list',
|
type: 'list',
|
||||||
choices: getLayouts,
|
choices: getLayouts,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'canonicalUrl',
|
||||||
|
message: 'Enter canonical url:',
|
||||||
|
type: 'input',
|
||||||
|
},
|
||||||
])
|
])
|
||||||
.then((answers) => {
|
.then((answers) => {
|
||||||
// Remove special characters and replace space with -
|
// Remove special characters and replace space with -
|
||||||
|
@ -29,6 +29,9 @@ const siteMetadata = require('../data/siteMetadata')
|
|||||||
if (fm.data.draft) {
|
if (fm.data.draft) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (fm.data.canonicalUrl) {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const path = page
|
const path = page
|
||||||
.replace('pages/', '/')
|
.replace('pages/', '/')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user