File tree Expand file tree Collapse file tree 5 files changed +8
-5
lines changed Expand file tree Collapse file tree 5 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ import {
1717 TWITTER_CREATOR ,
1818 BOOK_AUTHORS ,
1919 THEME_COLOR ,
20- CANONICAL_URL ,
2120} from ' @lib/const'
2221
2322export interface Props {
@@ -35,7 +34,7 @@ const {
3534 ogTitle = OG_TITLE ,
3635 ogDescription = OG_DESCRIPTION ,
3736 ogImage = OG_IMAGE ,
38- canonical = CANONICAL_URL ,
37+ canonical,
3938} = Astro .props
4039---
4140
@@ -64,7 +63,7 @@ const {
6463 <meta name =" theme-color" content ={ THEME_COLOR } />
6564
6665 <!-- Canonical URL -->
67- <link rel =" canonical" href ={ canonical } />
66+ { canonical && <link rel = " canonical" href = { canonical } />}
6867
6968 <!-- RSS Feed -->
7069 <link
Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ if (post.rendered?.metadata?.headings) {
6464 description ={ description }
6565 ogTitle ={ title }
6666 ogDescription ={ description }
67+ canonical ={ ` ${SITE_URL }/blog/${post .id } ` }
6768>
6869 <main class =" min-h-screen bg-base-100" >
6970 <!-- Blog Header -->
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ export const BOOK_EDITION = 'Fourth Edition'
3939export const BOOK_PUBLICATION_DATE = '2025-10-09'
4040
4141// Additional
42- export const CANONICAL_URL = 'https://nodejsdesignpatterns.com'
42+ export const DEFAULT_CANONICAL_URL = 'https://nodejsdesignpatterns.com'
4343export const THEME_COLOR = '#16a34a' // Green color from the design
4444
4545// Free chapter
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import BlogCard from '../../components/blog/BlogCard.astro'
55import Breadcrumb from ' @components/blog/Breadcrumb.astro'
66import Footer from ' @components/Footer.astro'
77import BookPromo from ' @components/blog/BookPromo.astro'
8+ import { SITE_URL } from ' @lib/const'
89
910// Get all blog posts, sorted by date (newest first)
1011const posts = (await getCollection (' blog' )).sort (
@@ -21,6 +22,7 @@ const pageDescription =
2122 description ={ pageDescription }
2223 ogTitle =" Blog - Node.js Design Patterns"
2324 ogDescription ={ pageDescription }
25+ canonical ={ ` ${SITE_URL }/blog/ ` }
2426>
2527 <main class =" min-h-screen bg-base-100" >
2628 <header class =" bg-gradient-to-b from-primary/40 to-primary/10" >
Original file line number Diff line number Diff line change @@ -15,9 +15,10 @@ import FreeChapter from '@components/pages/Home/FreeChapter.astro'
1515import Faq from ' @components/pages/Home/Faq.astro'
1616import Navigation from ' @components/Navigation.astro'
1717import Footer from ' @components/Footer.astro'
18+ import { DEFAULT_CANONICAL_URL } from ' @lib/const'
1819---
1920
20- <Layout >
21+ <Layout canonical = { ` ${ DEFAULT_CANONICAL_URL }/ ` } >
2122 <Navigation />
2223 <Hero />
2324 <Counters />
You can’t perform that action at this time.
0 commit comments