From 947943b9383b8dd3271da299dfaac46aa9475beb Mon Sep 17 00:00:00 2001 From: spences10 Date: Thu, 22 Aug 2024 20:38:14 +0100 Subject: [PATCH] docs: :memo: add in example code to docs --- apps/web/src/lib/copy/blog-posting-copy.md | 112 ++++++++++++ apps/web/src/lib/copy/breadcrumbs-copy.md | 119 +++++++++++++ apps/web/src/lib/copy/index-copy.md | 11 ++ .../copy/multiple-ld-json-sections-copy.md | 162 ++++++++++++++++++ apps/web/src/lib/copy/news-article-copy.md | 127 ++++++++++++++ apps/web/src/lib/copy/web-page-copy.md | 96 +++++++++++ apps/web/src/routes/blog-posting/+page.svelte | 4 + apps/web/src/routes/blog-posting/+page.ts | 13 ++ apps/web/src/routes/breadcrumbs/+page.svelte | 7 +- apps/web/src/routes/breadcrumbs/+page.ts | 13 ++ .../multiple-ld-json-sections/+page.svelte | 5 + .../routes/multiple-ld-json-sections/+page.ts | 13 ++ apps/web/src/routes/news-article/+page.svelte | 4 + apps/web/src/routes/news-article/+page.ts | 13 ++ apps/web/src/routes/web-page/+page.svelte | 4 + apps/web/src/routes/web-page/+page.ts | 13 ++ 16 files changed, 715 insertions(+), 1 deletion(-) create mode 100644 apps/web/src/lib/copy/blog-posting-copy.md create mode 100644 apps/web/src/lib/copy/multiple-ld-json-sections-copy.md create mode 100644 apps/web/src/lib/copy/news-article-copy.md create mode 100644 apps/web/src/lib/copy/web-page-copy.md create mode 100644 apps/web/src/routes/blog-posting/+page.ts create mode 100644 apps/web/src/routes/breadcrumbs/+page.ts create mode 100644 apps/web/src/routes/multiple-ld-json-sections/+page.ts create mode 100644 apps/web/src/routes/news-article/+page.ts create mode 100644 apps/web/src/routes/web-page/+page.ts diff --git a/apps/web/src/lib/copy/blog-posting-copy.md b/apps/web/src/lib/copy/blog-posting-copy.md new file mode 100644 index 0000000..44d7e3c --- /dev/null +++ b/apps/web/src/lib/copy/blog-posting-copy.md @@ -0,0 +1,112 @@ +Here's the code for this page: + +```svelte + + + + + +
+

{seo_config.title}

+

{seo_config.description}

+ + +
+``` diff --git a/apps/web/src/lib/copy/breadcrumbs-copy.md b/apps/web/src/lib/copy/breadcrumbs-copy.md index e69de29..db7a662 100644 --- a/apps/web/src/lib/copy/breadcrumbs-copy.md +++ b/apps/web/src/lib/copy/breadcrumbs-copy.md @@ -0,0 +1,119 @@ +Here's the code for this page: + +```svelte + + + + + +

{page_title}

+

{page_description}

+ + +``` diff --git a/apps/web/src/lib/copy/index-copy.md b/apps/web/src/lib/copy/index-copy.md index a4cd850..4dc77a5 100644 --- a/apps/web/src/lib/copy/index-copy.md +++ b/apps/web/src/lib/copy/index-copy.md @@ -20,6 +20,17 @@ Svead provides two main components: 1. `Head`: For setting meta tags and other head information. 2. `SchemaOrg`: For adding structured data using JSON-LD. +## Example Routes + +Explore how Svead works with different content types: + +- [Breadcrumbs](/breadcrumbs) +- [Article](/article) +- [Blog Posting](/blog-posting) +- [News Article](/news-article) +- [Web Page](/web-page) +- [Multiple JSON-LD Sections](/multiple-ld-json-sections) + ## Head Component ### Usage diff --git a/apps/web/src/lib/copy/multiple-ld-json-sections-copy.md b/apps/web/src/lib/copy/multiple-ld-json-sections-copy.md new file mode 100644 index 0000000..c859b9e --- /dev/null +++ b/apps/web/src/lib/copy/multiple-ld-json-sections-copy.md @@ -0,0 +1,162 @@ +Here's the code for this page: + +```svelte + + + + + +
+ + +

{seo_config.title}

+

{seo_config.description}

+ + + + +
+

Introduction to Structured Data

+

+ Structured data helps search engines understand the content of + your web pages... +

+
+ +
+

Implementing JSON-LD in SvelteKit

+

Here's how you can add JSON-LD to your SvelteKit project...

+
+ + + +
+

Author: {seo_config.author_name}

+

Published: {new Date().toLocaleDateString()}

+
+
+``` diff --git a/apps/web/src/lib/copy/news-article-copy.md b/apps/web/src/lib/copy/news-article-copy.md new file mode 100644 index 0000000..63f12a0 --- /dev/null +++ b/apps/web/src/lib/copy/news-article-copy.md @@ -0,0 +1,127 @@ +Here's the code for this page: + +```svelte + + + + + +
+

{seo_config.title}

+

{seo_config.description}

+ + +
+``` diff --git a/apps/web/src/lib/copy/web-page-copy.md b/apps/web/src/lib/copy/web-page-copy.md new file mode 100644 index 0000000..974bd03 --- /dev/null +++ b/apps/web/src/lib/copy/web-page-copy.md @@ -0,0 +1,96 @@ +Here's the code for this page: + +```svelte + + + + + +
+

{seo_config.title}

+

{seo_config.description}

+ + +
+``` diff --git a/apps/web/src/routes/blog-posting/+page.svelte b/apps/web/src/routes/blog-posting/+page.svelte index c544e89..a90b320 100644 --- a/apps/web/src/routes/blog-posting/+page.svelte +++ b/apps/web/src/routes/blog-posting/+page.svelte @@ -7,6 +7,9 @@ type SeoConfig, } from 'svead'; + export let data; + let { Copy } = data; + const get_current_iso_date = () => new Date().toISOString(); const seo_config: SeoConfig = { @@ -101,4 +104,5 @@

{seo_config.title}

{seo_config.description}

+ diff --git a/apps/web/src/routes/blog-posting/+page.ts b/apps/web/src/routes/blog-posting/+page.ts new file mode 100644 index 0000000..4e7e603 --- /dev/null +++ b/apps/web/src/routes/blog-posting/+page.ts @@ -0,0 +1,13 @@ +import { error } from '@sveltejs/kit'; + +export const load = async () => { + const slug = 'blog-posting-copy'; + try { + const Copy = await import(`../../lib/copy/${slug}.md`); + return { + Copy: Copy.default, + }; + } catch (e) { + throw error(404, 'Uh oh!'); + } +}; diff --git a/apps/web/src/routes/breadcrumbs/+page.svelte b/apps/web/src/routes/breadcrumbs/+page.svelte index 35b19b9..cb1c16a 100644 --- a/apps/web/src/routes/breadcrumbs/+page.svelte +++ b/apps/web/src/routes/breadcrumbs/+page.svelte @@ -3,8 +3,11 @@ import type { SchemaOrgProps, SeoConfig } from 'svead'; import { Head, SchemaOrg } from 'svead'; + export let data; + let { Copy } = data; + // Example data for the webpage - const page_title = 'Sample Web Page'; + const page_title = 'Sample Breadcrumbs Example'; const page_description = 'This is an example of a web page with enhanced SEO features.'; @@ -108,3 +111,5 @@

{page_title}

{page_description}

+ + diff --git a/apps/web/src/routes/breadcrumbs/+page.ts b/apps/web/src/routes/breadcrumbs/+page.ts new file mode 100644 index 0000000..7801cea --- /dev/null +++ b/apps/web/src/routes/breadcrumbs/+page.ts @@ -0,0 +1,13 @@ +import { error } from '@sveltejs/kit'; + +export const load = async () => { + const slug = 'breadcrumbs-copy'; + try { + const Copy = await import(`../../lib/copy/${slug}.md`); + return { + Copy: Copy.default, + }; + } catch (e) { + throw error(404, 'Uh oh!'); + } +}; diff --git a/apps/web/src/routes/multiple-ld-json-sections/+page.svelte b/apps/web/src/routes/multiple-ld-json-sections/+page.svelte index f39828d..1c04476 100644 --- a/apps/web/src/routes/multiple-ld-json-sections/+page.svelte +++ b/apps/web/src/routes/multiple-ld-json-sections/+page.svelte @@ -7,6 +7,9 @@ type SeoConfig, } from 'svead'; + export let data; + let { Copy } = data; + const get_current_iso_date = () => new Date().toISOString(); const seo_config: SeoConfig = { @@ -130,6 +133,8 @@

{seo_config.title}

{seo_config.description}

+ +

Introduction to Structured Data

diff --git a/apps/web/src/routes/multiple-ld-json-sections/+page.ts b/apps/web/src/routes/multiple-ld-json-sections/+page.ts new file mode 100644 index 0000000..11f4d82 --- /dev/null +++ b/apps/web/src/routes/multiple-ld-json-sections/+page.ts @@ -0,0 +1,13 @@ +import { error } from '@sveltejs/kit'; + +export const load = async () => { + const slug = 'multiple-ld-json-sections-copy'; + try { + const Copy = await import(`../../lib/copy/${slug}.md`); + return { + Copy: Copy.default, + }; + } catch (e) { + throw error(404, 'Uh oh!'); + } +}; diff --git a/apps/web/src/routes/news-article/+page.svelte b/apps/web/src/routes/news-article/+page.svelte index 7b42020..ef1670a 100644 --- a/apps/web/src/routes/news-article/+page.svelte +++ b/apps/web/src/routes/news-article/+page.svelte @@ -7,6 +7,9 @@ type SeoConfig, } from 'svead'; + export let data; + let { Copy } = data; + const seo_config: SeoConfig = { url: $page.url.href, website: 'https://example.com', @@ -116,4 +119,5 @@

{seo_config.title}

{seo_config.description}

+ diff --git a/apps/web/src/routes/news-article/+page.ts b/apps/web/src/routes/news-article/+page.ts new file mode 100644 index 0000000..e041ae6 --- /dev/null +++ b/apps/web/src/routes/news-article/+page.ts @@ -0,0 +1,13 @@ +import { error } from '@sveltejs/kit'; + +export const load = async () => { + const slug = 'news-article-copy'; + try { + const Copy = await import(`../../lib/copy/${slug}.md`); + return { + Copy: Copy.default, + }; + } catch (e) { + throw error(404, 'Uh oh!'); + } +}; diff --git a/apps/web/src/routes/web-page/+page.svelte b/apps/web/src/routes/web-page/+page.svelte index d7be1ed..566d716 100644 --- a/apps/web/src/routes/web-page/+page.svelte +++ b/apps/web/src/routes/web-page/+page.svelte @@ -7,6 +7,9 @@ type SeoConfig, } from 'svead'; + export let data; + let { Copy } = data; + const seo_config: SeoConfig = { url: $page.url.href, website: 'https://example.com', @@ -85,4 +88,5 @@

{seo_config.title}

{seo_config.description}

+ diff --git a/apps/web/src/routes/web-page/+page.ts b/apps/web/src/routes/web-page/+page.ts new file mode 100644 index 0000000..2c49e36 --- /dev/null +++ b/apps/web/src/routes/web-page/+page.ts @@ -0,0 +1,13 @@ +import { error } from '@sveltejs/kit'; + +export const load = async () => { + const slug = 'web-page-copy'; + try { + const Copy = await import(`../../lib/copy/${slug}.md`); + return { + Copy: Copy.default, + }; + } catch (e) { + throw error(404, 'Uh oh!'); + } +};