Skip to content

Commit

Permalink
SEO
Browse files Browse the repository at this point in the history
  • Loading branch information
LorisSigrist committed Oct 25, 2023
1 parent d596255 commit 9e34c39
Show file tree
Hide file tree
Showing 12 changed files with 180 additions and 3 deletions.
93 changes: 93 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"html-minifier": "^4.0.0",
"mdsvex": "^0.11.0",
"postcss": "^8.4.31",
"rehype-external-links": "^3.0.0",
"rehype-slug": "^6.0.0",
"svelte": "^3.54.0",
"svelte-check": "^3.0.1",
"tailwindcss": "^3.3.3",
Expand Down
17 changes: 17 additions & 0 deletions site/src/lib/seo/Metadata.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<script>
import { page } from "$app/stores";
const FALLBACK_TITLE = "T18S";
$: metadata = $page.data.metadata ?? {};
</script>
<svelte:head>
{#key $page.url.pathname}
<title>{metadata?.title ?? FALLBACK_TITLE}</title>
{#if metadata.description}
<meta name="description" content={metadata.description} />
{/if}
{/key}
</svelte:head>
4 changes: 4 additions & 0 deletions site/src/lib/seo/MetadataTypes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface Metadata {
title: string;
description: string;
}
4 changes: 3 additions & 1 deletion site/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<script>
import "$lib/app.css"
import { locale, setLocale } from "$t18s";
import { DEFAULT_LOCALE } from "$lib/i18n/index.js";
import HrefLang from "$lib/i18n/HrefLang.svelte";
import { browser } from "$app/environment";
import "$lib/app.css"
import Metadata from "$lib/seo/Metadata.svelte";
export let data;
$: setLocale(data.locale);
$: if(browser) document.documentElement.lang = $locale;
</script>

<Metadata />
<HrefLang defaultLocale={DEFAULT_LOCALE} />

<slot />
2 changes: 1 addition & 1 deletion site/src/routes/404/NotFoundPage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</script>

<svelte:head>
<meta name="robots" content="noindex">
<meta name="robots" content="noindex, nofollow">
<title>Page Not Found</title>
</svelte:head>

Expand Down
9 changes: 9 additions & 0 deletions site/src/routes/[[locale=locale]]/$t18s/+page.server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export function load() {
/** @type {import("$lib/seo/MetadataTypes").Metadata} */
const metadata = {
title: "$t18s Module Reference",
description: "Reference documentation for the $t18s module that's provided by t18s.",
};

return { metadata };
}
5 changes: 5 additions & 0 deletions site/src/routes/[[locale=locale]]/$t18s/+page.svx
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
title: $t18s Module Reference
description: Reference Documentation for the $t18s Module that is generated by t18s.
---

<script>
import CodeGroup from "$lib/ui/CodeGroup.svelte";
import Prism from "$lib/ui/Prism.svelte";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export function load() {
/** @type {import("$lib/seo/MetadataTypes").Metadata} */
const metadata = {
title: "Plugin Configuration",
description: "Reference documentation for the configuration of the t18s vite plugin.",
};

return { metadata };
}
9 changes: 9 additions & 0 deletions site/src/routes/[[locale=locale]]/seo/+page.server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export function load() {
/** @type {import("$lib/seo/MetadataTypes").Metadata} */
const metadata = {
title: "SEO",
description: "A guide to avoiding common SEO pitfalls when working with t18s.",
};

return { metadata };
}
9 changes: 9 additions & 0 deletions site/src/routes/[[locale=locale]]/syntax/+page.server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export function load() {
/** @type {import("$lib/seo/MetadataTypes").Metadata} */
const metadata = {
title: "Syntax",
description: "A guide to the ICU MessageFormat Syntax used by t18s.",
};

return { metadata };
}
20 changes: 19 additions & 1 deletion site/svelte.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
import adapter from "@sveltejs/adapter-static";
import { mdsvex } from "mdsvex";
import rehypeExternalLinks from "rehype-external-links";
import rehypeSlug from "rehype-slug";

/** @type {import('@sveltejs/kit').Config} */
const config = {
extensions: [".svelte", ".svx"],
preprocess: [mdsvex()],
preprocess: [
mdsvex({
smartypants: {
dashes: 'oldschool'
},
rehypePlugins: [
//@ts-ignore
[rehypeSlug, undefined],

[
// @ts-ignore
rehypeExternalLinks,
{ target: "_blank", rel: ["noopener", "noreferrer"] },
],
],
}),
],
kit: {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
Expand Down

0 comments on commit 9e34c39

Please sign in to comment.