fix(post): align microformat block with PostEntry types for svelte-check
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:
@@ -78,12 +78,12 @@
|
||||
itemtype={data.isEvent ? 'https://schema.org/Event' : 'https://schema.org/BlogPosting'}
|
||||
>
|
||||
<a class="u-url" href="#" aria-hidden="true" hidden></a>
|
||||
{#if data.post._created || data.post.created}
|
||||
{#if data.post.created}
|
||||
<time
|
||||
class="dt-published"
|
||||
datetime={String(data.post.created ?? data.post._created ?? '')}
|
||||
datetime={String(data.post.created)}
|
||||
hidden
|
||||
>{data.post.created ?? data.post._created}</time>
|
||||
>{data.post.created}</time>
|
||||
{/if}
|
||||
{#if data.contentHeadlineHtml}
|
||||
<div class="content markdown max-w-none prose prose-zinc p-name">
|
||||
@@ -121,15 +121,19 @@
|
||||
{/if}
|
||||
{#if (data.post.postTag ?? []).length > 0}
|
||||
<div hidden>
|
||||
{#each data.post.postTag ?? [] as tag}
|
||||
{#if tag && typeof tag === 'object' && 'name' in tag && tag.name}
|
||||
<span class="p-category">{tag.name}</span>
|
||||
{#each (data.post.postTag ?? []) as tag}
|
||||
{@const tagName =
|
||||
tag && typeof tag === 'object'
|
||||
? ((tag as { name?: string }).name ?? '')
|
||||
: ''}
|
||||
{#if tagName}
|
||||
<span class="p-category">{tagName}</span>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
<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>
|
||||
</article>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user