Skip to content

Commit 1480eea

Browse files
committed
✨ Add meta data
1 parent 389ed35 commit 1480eea

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

src/routes/docs/+layout.svelte

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212
}
1313
1414
const { children, data } = $props()
15+
const siteUrl = 'https://animated-java.github.io'
16+
const docsTitle = 'Animated Java Docs'
17+
const defaultDescription = 'Effortlessly craft complex animations for Minecraft: Java Edition'
18+
const socialImage = `${siteUrl}/images/armor_stand_wave.webp`
19+
20+
const pageTitle = $derived(
21+
data.currentDoc?.title ? `${data.currentDoc.title} | ${docsTitle}` : docsTitle
22+
)
23+
const pageDescription = $derived(
24+
data.currentDoc?.title ? `${data.currentDoc.title}` : defaultDescription
25+
)
26+
const canonicalUrl = $derived(`${siteUrl}${data.currentPath ?? '/docs/welcome'}`)
1527
1628
let tocHeadings = $state<TocHeading[]>([])
1729
let activeHeadingId = $state('')
@@ -169,6 +181,24 @@
169181
})
170182
</script>
171183

184+
<svelte:head>
185+
<title>{pageTitle}</title>
186+
<meta name="description" content={pageDescription} />
187+
<link rel="canonical" href={canonicalUrl} />
188+
189+
<meta property="og:type" content="website" />
190+
<meta property="og:site_name" content="Animated Java" />
191+
<meta property="og:title" content={pageTitle} />
192+
<meta property="og:description" content={pageDescription} />
193+
<meta property="og:url" content={canonicalUrl} />
194+
<meta property="og:image" content={socialImage} />
195+
196+
<meta name="twitter:card" content="summary_large_image" />
197+
<meta name="twitter:title" content={pageTitle} />
198+
<meta name="twitter:description" content={pageDescription} />
199+
<meta name="twitter:image" content={socialImage} />
200+
</svelte:head>
201+
172202
<div class="docs-shell">
173203
<header class="docs-header minecraft-box">
174204
<a href="/" class="brand-link">

src/routes/docs/+layout.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ function normalizedPath(pathname: string): string {
1111
export function load({ url }: { url: URL }) {
1212
const currentPath = normalizedPath(url.pathname)
1313
const currentIndex = flattenedDocs.findIndex(doc => doc.to === currentPath)
14+
const currentDoc = currentIndex >= 0 ? flattenedDocs[currentIndex] : null
1415

1516
let previous: DocLeaf | null = null
1617
let next: DocLeaf | null = null
@@ -24,6 +25,7 @@ export function load({ url }: { url: URL }) {
2425
docsNavLinks,
2526
docsSidebar,
2627
currentPath,
28+
currentDoc,
2729
previous,
2830
next,
2931
}

0 commit comments

Comments
 (0)