josh-collinsworth / sveltekit-blog-starter

A preconfigured SvelteKit static blog starter, with Sass, Markdown, MDSvex, Rehype, background preloading, and more. See the README for full details.
https://sveltekit-static-starter.netlify.app/
MIT License
419 stars 81 forks source link

Quick fix to PostsList component to handle undefined excerpts #27

Closed lakebayagency closed 1 year ago

lakebayagency commented 1 year ago

Simple fix to skip rendering "undefined" if your post doesn't have an excerpt:

{#if post.excerpt !== undefined}
    {post.excerpt}
{/if}
josh-collinsworth commented 1 year ago

Is there any reason not to just use this as the condition?

{#if post.excerpt}
lakebayagency commented 1 year ago

Only my ignorance! 🙂

josh-collinsworth commented 1 year ago

After some consideration, I don't think this should be fixed, since the excerpt data is also used by the meta tags present on the post pages. My feeling is that the project probably shouldn't treat a frontmatter prop as optional when it goes into the SEO of the published site.

Naturally, it's just a starter and authors can remove it if they like. I think this should probably remain as the "happy path" for the time being, though.