From 0e30d0a539f4e5a85da349ed8727dd0f79feeeac Mon Sep 17 00:00:00 2001 From: Matthieu Morin Date: Wed, 3 Apr 2024 16:36:27 +0200 Subject: [PATCH] Reactive SEO - Global default in root layout, reactive reusable component, data props --- src/lib/components/SEO.svelte | 150 ++++++++++++++++++ .../SEOopenGraph/OpenGraphPost.svelte | 20 --- src/lib/components/SEOopenGraph/SEO.svelte | 56 ------- src/routes/+layout.svelte | 58 ++++--- 4 files changed, 184 insertions(+), 100 deletions(-) create mode 100644 src/lib/components/SEO.svelte delete mode 100644 src/lib/components/SEOopenGraph/OpenGraphPost.svelte delete mode 100644 src/lib/components/SEOopenGraph/SEO.svelte diff --git a/src/lib/components/SEO.svelte b/src/lib/components/SEO.svelte new file mode 100644 index 0000000..545435b --- /dev/null +++ b/src/lib/components/SEO.svelte @@ -0,0 +1,150 @@ + + + + + + {title} + + + + + + {#if description} + + {/if} + + + + {#if canonical} + + {/if} + + + + + + {#if description} + + {/if} + + {#if canonical} + + {/if} + + + + + + + + {#if twitter?.description || description} + + {/if} + + + + + {#if frontmatter?} + + {:else} + + {/if} + + {#if frontmatter?.date} + + {/if} + + {#if frontmatter?.tags} + {#each frontmatter.tags as tag} + + {/each} + {/if} + diff --git a/src/lib/components/SEOopenGraph/OpenGraphPost.svelte b/src/lib/components/SEOopenGraph/OpenGraphPost.svelte deleted file mode 100644 index ed36126..0000000 --- a/src/lib/components/SEOopenGraph/OpenGraphPost.svelte +++ /dev/null @@ -1,20 +0,0 @@ - - - - {openGraphData.title} - - - - - - - - {#each tags as tag (tag)} - - {/each} - diff --git a/src/lib/components/SEOopenGraph/SEO.svelte b/src/lib/components/SEOopenGraph/SEO.svelte deleted file mode 100644 index dee3304..0000000 --- a/src/lib/components/SEOopenGraph/SEO.svelte +++ /dev/null @@ -1,56 +0,0 @@ - - - - {data.title} - - - {#if data.description} - - {/if} - - {#if data.canonical} - - {/if} - - - - - {#if data.description} - - {/if} - {#if data.canonical} - - {/if} - - - - - - - {#if data.description} - - {/if} - - - - {#each data.frontmatter?.tags as tag (tag)} - - {/each} - - diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index d6efa45..a694267 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -27,24 +27,34 @@ import MainFooter from '$lib/components/MainFooter.svelte'; // SEO Meta tags - const metaDefaults = { - title: 'BeautySalon', - description: 'BeautySalon Popis.', - image: 'https://user-images.githubusercontent.com/1509726/212382766-f29b9c9a-82e3-44c2-b911-b17a9197e5b9.jpg' - }; - const meta = { - title: metaDefaults.title, - description: metaDefaults.description, - image: metaDefaults.image, - // Article - article: { publishTime: '', modifiedTime: '', author: '' }, - // Twitter - twitter: { - title: metaDefaults.title, - description: metaDefaults.description, - image: metaDefaults.image - } - }; + import SEO from '$lib/components/SEO.svelte' + + $: seoData = $page.data.seoData || { + title: 'KKosmetickySalon - Klára Morinová', + description: 'Přijeďte si ke mně pro odbornou péči o Vaši pleť. Jsem certifikovaná kosmetička a makeup artistka, provádím Permanentní Make-up, vizážistiku, ošetřovací a zeštihlovací procedury, a mnoho dalšího... Vše s ohledem na vaše zdraví. Zarezervujte si péči o svůj vzhled přes moje stránky nyní!', + keywords: 'kosmetika, vizáž, pleť, Písek, kosmetička, permanentní makeup, ', + image: '/logo-text.png', + type: 'website', + }; + + // const metaDefaults = { + // title: 'BeautySalon', + // description: 'BeautySalon Popis.', + // image: 'https://user-images.githubusercontent.com/1509726/212382766-f29b9c9a-82e3-44c2-b911-b17a9197e5b9.jpg' + // }; + // const meta = { + // title: metaDefaults.title, + // description: metaDefaults.description, + // image: metaDefaults.image, + // // Article + // article: { publishTime: '', modifiedTime: '', author: '' }, + // // Twitter + // twitter: { + // title: metaDefaults.title, + // description: metaDefaults.description, + // image: metaDefaults.image + // } + // }; // Scroll to anchor @@ -63,15 +73,15 @@ - + + Meta Tags - + Open Graph - https://ogp.me/ @@ -84,12 +94,12 @@ - + Open Graph: Twitter - - + --> +