diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 072965e..356ae87 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -6,7 +6,7 @@ import '@fontsource-variable/m-plus-1-code'; import { getEntry } from 'astro:content'; -import type { Article, WithContext } from 'schema-dts'; +import type { Article, WebSite, WithContext } from 'schema-dts'; import GoogleAnalytics from '@/components/analytics/GoogleAnalytics.astro'; import Footer from '@/components/Footer.astro'; @@ -30,7 +30,7 @@ export type Props = { path: string; hreflang: keyof typeof ui | 'x-default'; }[]; - jsonLdSchema?: WithContext
; + jsonLdSchema?: WithContext
| WebSite; }; const { title, description, path, og, lang, hreflangs, jsonLdSchema } = diff --git a/src/lib/rich-results.ts b/src/lib/rich-results.ts index 9283ddf..a36e956 100644 --- a/src/lib/rich-results.ts +++ b/src/lib/rich-results.ts @@ -38,7 +38,7 @@ const publisher = (site: URL | '', lang: keyof typeof ui): Organization => { }; }; -const website = ( +export const WebsiteLd = ( meta: CollectionEntry<'site'>, site: URL | '', lang: keyof typeof ui, @@ -79,6 +79,6 @@ export const ArticleLd = ( inLanguage: supportLangs, author: [person(meta)], publisher: publisher(site, lang), - isPartOf: website(meta, site, lang), + isPartOf: WebsiteLd(meta, site, lang), }; }; diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index f8ce279..3f3bfea 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -10,7 +10,7 @@ import { BlogDate } from '@/components/markdown/blog-date'; import { BlogMeta } from '@/components/markdown/blog-meta'; import Image from '@/components/markdown/Image.astro'; import { Separator } from '@/components/ui/separator'; -import { defaultLang, ui } from '@/i18n/ui'; +import { ui } from '@/i18n/ui'; import { useTranslatedPath, useTranslations } from '@/i18n/utils'; import { getLangFromUrl } from '@/i18n/utils'; import Layout from '@/layouts/Layout.astro'; @@ -70,7 +70,7 @@ const defaultImagePath = '/first-place.jpg'; type: 'article', }} hreflangs={[ - { path: `${path}`, hreflang: defaultLang }, + { path: `${path}`, hreflang: globalLang }, { path: `${path}`, hreflang: 'x-default' }, ]} jsonLdSchema={ArticleLd(meta, post, site, globalLang)} diff --git a/src/pages/index.astro b/src/pages/index.astro index 430a80a..38b690f 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,10 +1,15 @@ --- +import { getEntry } from 'astro:content'; + import { defaultLang } from '@/i18n/ui'; import { getLangFromUrl, useTranslations } from '@/i18n/utils'; import Layout from '@/layouts/Layout.astro'; +import { WebsiteLd } from '@/lib/rich-results'; const lang = getLangFromUrl(Astro.url); const t = useTranslations(lang); +const site = Astro.site ?? ''; +const meta = await getEntry('site', 'meta'); ---

{t('main.title')}