TheDahoom / Sveltekit-seo

Sveltekit SEO component to save your time
https://skseo.dev
MIT License
121 stars 3 forks source link

The title conditions #5

Open fabianmossberg opened 5 days ago

fabianmossberg commented 5 days ago

Is there any good reson why some things are only shown if there is a title set?

https://github.com/TheDahoom/Sveltekit-seo/blob/bcc9433a15e5a93f29ee8f47cee1757c9f22886f/SEO.svelte#L28-L36

To me, it would make more sense if it looked like this:

<!-- Only the tilte is depending on the title to be set -->
{#if title !== ""} 
    <title>{title}</title> 
{/if} 

<!-- This should not be dependent on the title -->
{#if imageURL} 
    <meta name="robots" content={index ? "index, follow, max-image-preview:large" : "noindex"}> 
{:else} 
    <meta name="robots" content={index ? "index, follow" : "noindex"}> 
{/if} 

<!-- This should defineltey not be dependent on the title -->
<link rel="canonical" content="{canonical === '' ? $page.url : canonical}"> 
TheDahoom commented 5 days ago

The plan is for <SEO> to be reusable across multiple components/pages. The title element is like a buffer so that when reusing SEO for different elements, the and tag isn't duplicated multiple times with it.

I attempted to add javascript checks to have this more streamlined but that broke either ssr or prerendered pages, cant remember which to be honest. I also tried a bunch of other ideas but nothing worked without breaking something else. I found using this modular approach to be best for now.

If you have any ideas to fix the duplication issue I'd love to give them a shot.