Skip to content

Commit

Permalink
feat(examples-*): add keys to <Head> elements to prevent duplicate me…
Browse files Browse the repository at this point in the history
…ta tags

Fixes #416
  • Loading branch information
PierreRe authored Feb 22, 2024
1 parent e245aba commit 81b3830
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
7 changes: 5 additions & 2 deletions examples/example-blog/components/meta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export function Meta({ title, tags }: MetaProps) {
return (
<Head>
<link
key="canonical_link"
rel="canonical"
href={`${process.env.NEXT_PUBLIC_BASE_URL}${
router.asPath !== "/" ? router.asPath : ""
Expand All @@ -37,15 +38,17 @@ export function Meta({ title, tags }: MetaProps) {
<>
<title>{`${title} | Next.js for Drupal`}</title>
<meta
key="description"
name="description"
content="A Next.js blog powered by a Drupal backend."
/>
<meta
key="og_image"
property="og:image"
content={`${process.env.NEXT_PUBLIC_BASE_URL}/images/meta.jpg`}
/>
<meta property="og:image:width" content="800" />
<meta property="og:image:height" content="600" />
<meta key="og_image_width" property="og:image:width" content="800" />
<meta key="og_image_height" property="og:image:height" content="600" />
</>
)}
</Head>
Expand Down
2 changes: 1 addition & 1 deletion examples/example-graphql/pages/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function NodePage({ resource }) {
<Layout>
<Head>
<title>{resource.title}</title>
<meta name="description" content="A Next.js site powered by Drupal." />
<meta key="description" name="description" content="A Next.js site powered by Drupal." />
</Head>
{resource && <NodeArticle node={resource} />}
</Layout>
Expand Down
1 change: 1 addition & 0 deletions examples/example-graphql/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default function IndexPage({ articles }) {
<Head>
<title>Next.js for Drupal</title>
<meta
key="description"
name="description"
content="A Next.js site powered by a Drupal backend."
/>
Expand Down
7 changes: 5 additions & 2 deletions examples/example-marketing/components/meta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export function Meta({ title, tags }: MetaProps) {
return (
<Head>
<link
key="canonical_link"
rel="canonical"
href={`${process.env.NEXT_PUBLIC_BASE_URL}${
router.asPath !== "/" ? router.asPath : ""
Expand All @@ -37,15 +38,17 @@ export function Meta({ title, tags }: MetaProps) {
<>
<title>{`${title} | Next.js for Drupal`}</title>
<meta
key="description"
name="description"
content="A Next.js blog powered by a Drupal backend."
/>
<meta
key="og_image"
property="og:image"
content={`${process.env.NEXT_PUBLIC_BASE_URL}/images/meta.jpg`}
/>
<meta property="og:image:width" content="800" />
<meta property="og:image:height" content="600" />
<meta key="og_image_width" property="og:image:width" content="800" />
<meta key="og_image_height" property="og:image:height" content="600" />
</>
)}
</Head>
Expand Down
1 change: 1 addition & 0 deletions examples/example-query/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function IndexPage({
<Head>
<title>Example Query</title>
<meta
key="description"
name="description"
content="A Next.js site powered by a Drupal backend."
/>
Expand Down
8 changes: 5 additions & 3 deletions examples/example-umami/components/meta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ export function Meta({ title, description }: MetaProps) {
return (
<Head>
<link
key="canonical_link"
rel="canonical"
href={absoluteURL(router.asPath !== "/" ? router.asPath : "")}
/>
<title>{`${title} | ${siteConfig.name}`}</title>
<meta name="description" content={description || siteConfig.slogan} />
<meta key="description" name="description" content={description || siteConfig.slogan} />
<meta
key="og_image"
property="og:image"
content={`${process.env.NEXT_PUBLIC_BASE_URL}/images/meta.jpg`}
/>
<meta property="og:image:width" content="800" />
<meta property="og:image:height" content="600" />
<meta key="og_image_width" property="og:image:width" content="800" />
<meta key="og_image_height" property="og:image:height" content="600" />
</Head>
)
}

0 comments on commit 81b3830

Please sign in to comment.