Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
TWITTER_CREATOR,
BOOK_AUTHORS,
THEME_COLOR,
CANONICAL_URL,
} from '@lib/const'

export interface Props {
Expand All @@ -35,7 +34,7 @@ const {
ogTitle = OG_TITLE,
ogDescription = OG_DESCRIPTION,
ogImage = OG_IMAGE,
canonical = CANONICAL_URL,
canonical,
} = Astro.props
---

Expand Down Expand Up @@ -64,7 +63,7 @@ const {
<meta name="theme-color" content={THEME_COLOR} />

<!-- Canonical URL -->
<link rel="canonical" href={canonical} />
{canonical && <link rel="canonical" href={canonical} />}

<!-- RSS Feed -->
<link
Expand Down
1 change: 1 addition & 0 deletions src/components/blog/BlogLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ if (post.rendered?.metadata?.headings) {
description={description}
ogTitle={title}
ogDescription={description}
canonical={`${SITE_URL}/blog/${post.id}`}
>
<main class="min-h-screen bg-base-100">
<!-- Blog Header -->
Expand Down
2 changes: 1 addition & 1 deletion src/lib/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const BOOK_EDITION = 'Fourth Edition'
export const BOOK_PUBLICATION_DATE = '2025-10-09'

// Additional
export const CANONICAL_URL = 'https://nodejsdesignpatterns.com'
export const DEFAULT_CANONICAL_URL = 'https://nodejsdesignpatterns.com'
export const THEME_COLOR = '#16a34a' // Green color from the design

// Free chapter
Expand Down
2 changes: 2 additions & 0 deletions src/pages/blog/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import BlogCard from '../../components/blog/BlogCard.astro'
import Breadcrumb from '@components/blog/Breadcrumb.astro'
import Footer from '@components/Footer.astro'
import BookPromo from '@components/blog/BookPromo.astro'
import { SITE_URL } from '@lib/const'

// Get all blog posts, sorted by date (newest first)
const posts = (await getCollection('blog')).sort(
Expand All @@ -21,6 +22,7 @@ const pageDescription =
description={pageDescription}
ogTitle="Blog - Node.js Design Patterns"
ogDescription={pageDescription}
canonical={`${SITE_URL}/blog/`}
>
<main class="min-h-screen bg-base-100">
<header class="bg-gradient-to-b from-primary/40 to-primary/10">
Expand Down
3 changes: 2 additions & 1 deletion src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import FreeChapter from '@components/pages/Home/FreeChapter.astro'
import Faq from '@components/pages/Home/Faq.astro'
import Navigation from '@components/Navigation.astro'
import Footer from '@components/Footer.astro'
import { DEFAULT_CANONICAL_URL } from '@lib/const'
---

<Layout>
<Layout canonical={`${DEFAULT_CANONICAL_URL}/`}>
<Navigation />
<Hero />
<Counters />
Expand Down