Skip to content

Commit

Permalink
bookmarks: set canonical link to original source
Browse files Browse the repository at this point in the history
  • Loading branch information
ooloth committed Dec 23, 2024
1 parent bac176b commit 45c21ac
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/layouts/Base.astro
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ import { getTILs } from '../utils/tils'
import { getBookmarks } from '../utils/bookmarks'
export type BaseProps = {
canonicalUrl?: string
description?: string
ogImage?: string
title?: string
}
type Props = BaseProps
const { description, ogImage, title } = Astro.props
const { pathname } = Astro.url
const { canonicalUrl, description, ogImage, title } = Astro.props
const { href, pathname } = Astro.url
const posts = await getPosts()
const tils = await getTILs()
Expand Down Expand Up @@ -144,7 +145,7 @@ const socialImage = ogImage
<title>{pageTitleWithSuffix}</title>
<meta name="description" content={pageDescription} />
<meta name="author" content={site.author.name} />
<link rel="canonical" href={Astro.url.href} />
<link rel="canonical" href={canonicalUrl || href} />
<link rel="sitemap" href="/sitemap.xml" />

<!-- Open Graph (see: https://ogp.me) -->
Expand Down
4 changes: 2 additions & 2 deletions src/layouts/Main.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import Base, { type BaseProps } from './Base.astro'
type Props = BaseProps
const { description, title, ogImage } = Astro.props
const { description, title, ogImage, canonicalUrl } = Astro.props
---

<Base title={title} description={description} ogImage={ogImage}>
<Base title={title} description={description} ogImage={ogImage} canonicalUrl={canonicalUrl}>
<div class="flex flex-col flex-1">
<Header />

Expand Down
2 changes: 1 addition & 1 deletion src/layouts/Writing.astro
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const isDraft = isPathnameInCollection(pathname, drafts)
// const tags = cleanTags(entry.data.tags)
---

<Main title={title} description={entry.data.description} ogImage={entry.data.ogImage}>
<Main canonicalUrl={entry.data.source} description={entry.data.description} ogImage={entry.data.ogImage} title={title}>
<div class="mx-auto max-w-2xl">
<header class="markdown">
{
Expand Down

0 comments on commit 45c21ac

Please sign in to comment.