From 9e34c39a7e2003aea61fc47ba00f550902d7753c Mon Sep 17 00:00:00 2001 From: Loris Sigrist Date: Wed, 25 Oct 2023 15:21:05 +0200 Subject: [PATCH] SEO --- pnpm-lock.yaml | 93 +++++++++++++++++++ site/package.json | 2 + site/src/lib/seo/Metadata.svelte | 17 ++++ site/src/lib/seo/MetadataTypes.d.ts | 4 + site/src/routes/+layout.svelte | 4 +- site/src/routes/404/NotFoundPage.svelte | 2 +- .../[[locale=locale]]/$t18s/+page.server.js | 9 ++ .../routes/[[locale=locale]]/$t18s/+page.svx | 5 + .../plugin-config/+page.server.js | 9 ++ .../[[locale=locale]]/seo/+page.server.js | 9 ++ .../[[locale=locale]]/syntax/+page.server.js | 9 ++ site/svelte.config.js | 20 +++- 12 files changed, 180 insertions(+), 3 deletions(-) create mode 100644 site/src/lib/seo/Metadata.svelte create mode 100644 site/src/lib/seo/MetadataTypes.d.ts create mode 100644 site/src/routes/[[locale=locale]]/$t18s/+page.server.js create mode 100644 site/src/routes/[[locale=locale]]/plugin-config/+page.server.js create mode 100644 site/src/routes/[[locale=locale]]/seo/+page.server.js create mode 100644 site/src/routes/[[locale=locale]]/syntax/+page.server.js diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a0613fd..4e02f2f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -102,6 +102,12 @@ importers: postcss: specifier: ^8.4.31 version: 8.4.31 + rehype-external-links: + specifier: ^3.0.0 + version: 3.0.0 + rehype-slug: + specifier: ^6.0.0 + version: 6.0.0 svelte: specifier: ^3.54.0 version: 3.59.2 @@ -627,6 +633,12 @@ packages: resolution: {integrity: sha512-CS2rOaoQ/eAgAfcTfq6amKG7bsN+EMcgGY4FAFQdvSj2y1ixvOZTUA9mOtCai7E1SYu283XNw7urKK30nP3wkQ==} dev: false + /@types/hast@3.0.2: + resolution: {integrity: sha512-B5hZHgHsXvfCoO3xgNJvBnX7N8p86TqQeGKXcokW4XXi+qY4vxxPSFYofytvVmpFxzPv7oxDQzjg5Un5m2/xiw==} + dependencies: + '@types/unist': 2.0.9 + dev: true + /@types/js-yaml@4.0.6: resolution: {integrity: sha512-ACTuifTSIIbyksx2HTon3aFtCKWcID7/h3XEmRpDYdMCXxPbl+m9GteOJeaAkiAta/NJaSFuA7ahZ0NkwajDSw==} dev: true @@ -642,6 +654,14 @@ packages: resolution: {integrity: sha512-zC0iXxAv1C1ERURduJueYzkzZ2zaGyc+P2c95hgkikHPr3z8EdUZOlgEQ5X0DRmwDZn+hekycQnoeiiRVrmilQ==} dev: true + /@types/unist@3.0.1: + resolution: {integrity: sha512-ue/hDUpPjC85m+PM9OQDMZr3LywT+CT6mPsQq8OJtCLiERkGRcQUFvu9XASF5XWqyZFXbf15lvb3JFJ4dRLWPg==} + dev: true + + /@ungap/structured-clone@1.2.0: + resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} + dev: true + /@vitest/expect@0.34.6: resolution: {integrity: sha512-QUzKpUQRc1qC7qdGo7rMK3AkETI7w18gTCUrsNnyjjJKYiuUB9+TQK3QnR1unhCnWRC0AbKv2omLGQDF/mIjOw==} dependencies: @@ -1099,6 +1119,10 @@ packages: engines: {node: '>=10'} dev: true + /github-slugger@2.0.0: + resolution: {integrity: sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw==} + dev: true + /glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -1152,6 +1176,24 @@ packages: engines: {node: '>= 0.4.0'} dev: true + /hast-util-heading-rank@3.0.0: + resolution: {integrity: sha512-EJKb8oMUXVHcWZTDepnr+WNbfnXKFNf9duMesmr4S8SXTJBJ9M4Yok08pu9vxdJwdlGRhVumk9mEhkEvKGifwA==} + dependencies: + '@types/hast': 3.0.2 + dev: true + + /hast-util-is-element@3.0.0: + resolution: {integrity: sha512-Val9mnv2IWpLbNPqc/pUem+a7Ipj2aHacCwgNfTiK0vJKl0LF+4Ba4+v1oPHFpf3bLYmreq0/l3Gud9S5OH42g==} + dependencies: + '@types/hast': 3.0.2 + dev: true + + /hast-util-to-string@3.0.0: + resolution: {integrity: sha512-OGkAxX1Ua3cbcW6EJ5pT/tslVb90uViVkcJ4ZZIMW/R33DX/AkcJcRrPebPwJkHYwlDHXz4aIwvAAaAdtrACFA==} + dependencies: + '@types/hast': 3.0.2 + dev: true + /he@1.2.0: resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==} hasBin: true @@ -1204,6 +1246,11 @@ packages: tslib: 2.6.2 dev: true + /is-absolute-url@4.0.1: + resolution: {integrity: sha512-/51/TKE88Lmm7Gc4/8btclNXWS+g50wXhYJq8HWIBAGUBnoAdRu1aXeh364t/O7wXDAcTJDP8PNuNKWUDWie+A==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dev: true + /is-binary-path@2.1.0: resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} engines: {node: '>=8'} @@ -1712,6 +1759,27 @@ packages: picomatch: 2.3.1 dev: true + /rehype-external-links@3.0.0: + resolution: {integrity: sha512-yp+e5N9V3C6bwBeAC4n796kc86M4gJCdlVhiMTxIrJG5UHDMh+PJANf9heqORJbt1nrCbDwIlAZKjANIaVBbvw==} + dependencies: + '@types/hast': 3.0.2 + '@ungap/structured-clone': 1.2.0 + hast-util-is-element: 3.0.0 + is-absolute-url: 4.0.1 + space-separated-tokens: 2.0.2 + unist-util-visit: 5.0.0 + dev: true + + /rehype-slug@6.0.0: + resolution: {integrity: sha512-lWyvf/jwu+oS5+hL5eClVd3hNdmwM1kAC0BUvEGD19pajQMIzcNUd/k9GsfQ+FfECvX+JE+e9/btsKH0EjJT6A==} + dependencies: + '@types/hast': 3.0.2 + github-slugger: 2.0.0 + hast-util-heading-rank: 3.0.0 + hast-util-to-string: 3.0.0 + unist-util-visit: 5.0.0 + dev: true + /relateurl@0.2.7: resolution: {integrity: sha512-G08Dxvm4iDN3MLM0EsP62EDV9IuhXPR6blNz6Utcp7zyV3tr4HVNINt6MpaRWbxoOHT3Q7YN2P+jaHX8vUbgog==} engines: {node: '>= 0.10'} @@ -1824,6 +1892,10 @@ packages: engines: {node: '>=0.10.0'} dev: true + /space-separated-tokens@2.0.2: + resolution: {integrity: sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==} + dev: true + /stackback@0.0.2: resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} dev: true @@ -2117,12 +2189,33 @@ packages: '@fastify/busboy': 2.0.0 dev: true + /unist-util-is@6.0.0: + resolution: {integrity: sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==} + dependencies: + '@types/unist': 3.0.1 + dev: true + /unist-util-stringify-position@2.0.3: resolution: {integrity: sha512-3faScn5I+hy9VleOq/qNbAd6pAx7iH5jYBMS9I1HgQVijz/4mv5Bvw5iw1sC/90CODiKo81G/ps8AJrISn687g==} dependencies: '@types/unist': 2.0.9 dev: true + /unist-util-visit-parents@6.0.1: + resolution: {integrity: sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==} + dependencies: + '@types/unist': 3.0.1 + unist-util-is: 6.0.0 + dev: true + + /unist-util-visit@5.0.0: + resolution: {integrity: sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==} + dependencies: + '@types/unist': 3.0.1 + unist-util-is: 6.0.0 + unist-util-visit-parents: 6.0.1 + dev: true + /unplugin-icons@0.17.1: resolution: {integrity: sha512-KsWejBPCHokYCNDQUzGu6R3E3XDYH/YpewgQwrVBXgpl1iR0RdW1NEGNdjlbuapwVnZXVgA5eiDTfNaQCawSdg==} peerDependencies: diff --git a/site/package.json b/site/package.json index 281f461..241cc52 100644 --- a/site/package.json +++ b/site/package.json @@ -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", diff --git a/site/src/lib/seo/Metadata.svelte b/site/src/lib/seo/Metadata.svelte new file mode 100644 index 0000000..2c84527 --- /dev/null +++ b/site/src/lib/seo/Metadata.svelte @@ -0,0 +1,17 @@ + + + + {#key $page.url.pathname} + {metadata?.title ?? FALLBACK_TITLE} + + {#if metadata.description} + + {/if} + {/key} + diff --git a/site/src/lib/seo/MetadataTypes.d.ts b/site/src/lib/seo/MetadataTypes.d.ts new file mode 100644 index 0000000..e400137 --- /dev/null +++ b/site/src/lib/seo/MetadataTypes.d.ts @@ -0,0 +1,4 @@ +export interface Metadata { + title: string; + description: string; +} \ No newline at end of file diff --git a/site/src/routes/+layout.svelte b/site/src/routes/+layout.svelte index f01209d..b335549 100644 --- a/site/src/routes/+layout.svelte +++ b/site/src/routes/+layout.svelte @@ -1,15 +1,17 @@ + \ No newline at end of file diff --git a/site/src/routes/404/NotFoundPage.svelte b/site/src/routes/404/NotFoundPage.svelte index ed8d2c4..0c4eb31 100644 --- a/site/src/routes/404/NotFoundPage.svelte +++ b/site/src/routes/404/NotFoundPage.svelte @@ -3,7 +3,7 @@ - + Page Not Found diff --git a/site/src/routes/[[locale=locale]]/$t18s/+page.server.js b/site/src/routes/[[locale=locale]]/$t18s/+page.server.js new file mode 100644 index 0000000..2a52e67 --- /dev/null +++ b/site/src/routes/[[locale=locale]]/$t18s/+page.server.js @@ -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 }; +} diff --git a/site/src/routes/[[locale=locale]]/$t18s/+page.svx b/site/src/routes/[[locale=locale]]/$t18s/+page.svx index 9b473fb..b24cb09 100644 --- a/site/src/routes/[[locale=locale]]/$t18s/+page.svx +++ b/site/src/routes/[[locale=locale]]/$t18s/+page.svx @@ -1,3 +1,8 @@ +--- +title: $t18s Module Reference +description: Reference Documentation for the $t18s Module that is generated by t18s. +--- +