fix(post): align microformat block with PostEntry types for svelte-check
Deploy / verify (push) Successful in 37s
Deploy / deploy (push) Successful in 1m0s

Three CI typecheck failures from the previous microformat patch:

- post.created is the only date field in the schema (no _created on the
  generated PostEntry). Drop the _created fallback.
- postTag items can be a slug string OR a tag object. Type narrowing
  with `'name' in tag` widened to `never`; pull the name through an
  explicit `{ name?: string }` cast in @const so the iteration stays
  honest about the runtime shape.
- author isn't on PostEntry either; cast at the use-site for the
  hidden h-card author block.
This commit is contained in:
Peter Meier
2026-04-25 09:22:18 +02:00
parent 1ff4dc7a9a
commit bb9df1f9bd
+11 -7
View File
@@ -78,12 +78,12 @@
itemtype={data.isEvent ? 'https://schema.org/Event' : 'https://schema.org/BlogPosting'} itemtype={data.isEvent ? 'https://schema.org/Event' : 'https://schema.org/BlogPosting'}
> >
<a class="u-url" href="#" aria-hidden="true" hidden></a> <a class="u-url" href="#" aria-hidden="true" hidden></a>
{#if data.post._created || data.post.created} {#if data.post.created}
<time <time
class="dt-published" class="dt-published"
datetime={String(data.post.created ?? data.post._created ?? '')} datetime={String(data.post.created)}
hidden hidden
>{data.post.created ?? data.post._created}</time> >{data.post.created}</time>
{/if} {/if}
{#if data.contentHeadlineHtml} {#if data.contentHeadlineHtml}
<div class="content markdown max-w-none prose prose-zinc p-name"> <div class="content markdown max-w-none prose prose-zinc p-name">
@@ -121,15 +121,19 @@
{/if} {/if}
{#if (data.post.postTag ?? []).length > 0} {#if (data.post.postTag ?? []).length > 0}
<div hidden> <div hidden>
{#each data.post.postTag ?? [] as tag} {#each (data.post.postTag ?? []) as tag}
{#if tag && typeof tag === 'object' && 'name' in tag && tag.name} {@const tagName =
<span class="p-category">{tag.name}</span> tag && typeof tag === 'object'
? ((tag as { name?: string }).name ?? '')
: ''}
{#if tagName}
<span class="p-category">{tagName}</span>
{/if} {/if}
{/each} {/each}
</div> </div>
{/if} {/if}
<div class="p-author h-card" hidden> <div class="p-author h-card" hidden>
<span class="p-name">{data.post.author ?? 'Bürgerinitiative Vachdorf'}</span> <span class="p-name">{(data.post as { author?: string }).author ?? 'Bürgerinitiative Vachdorf'}</span>
</div> </div>
</article> </article>