feat(website): allow images in readmes

This commit is contained in:
daimond113 2024-04-08 18:15:21 +02:00
parent 10f0042ac3
commit d6c80ac2a1
No known key found for this signature in database
GPG key ID: 3A8ECE51328B513C
2 changed files with 7 additions and 20 deletions

View file

@ -25,25 +25,9 @@
$: markdown =
data.readme &&
DOMPurify.sanitize($md?.render(data.readme) ?? '', {
FORBID_ATTR: ['src'],
FORBID_TAGS: [
'script',
'style',
'img',
'video',
'audio',
'iframe',
'object',
'embed',
'canvas',
'source'
]
FORBID_TAGS: ['script', 'style', 'audio', 'iframe', 'object', 'embed', 'canvas']
});
$: publishedAt = new Date(
(data.versions.find(([version]) => version === data.version)?.[1] ?? 0) * 1000
);
$: allDependencies = [
[data.dependencies, 'Dependencies'],
[data.peerDependencies, 'Peer Dependencies']
@ -84,7 +68,7 @@
goto(`/packages/${data.scope}/${data.name}/${event.target?.value}`);
}}
>
{#each data.versions as [version]}
{#each data.versions as version}
<option value={version} selected={version === data.version}>{version}</option>
{/each}
</select>
@ -94,7 +78,7 @@
<section>
<div class="section-title">Published at</div>
<div class="flex items-center gap-2">
<time datetime={publishedAt.toISOString()}>{publishedAt.toLocaleString()}</time>
<time datetime={data.publishedAt.toISOString()}>{data.publishedAt.toLocaleString()}</time>
</div>
</section>
<section>

View file

@ -113,7 +113,10 @@ export const load: PageLoad = async ({ params, fetch }) => {
scope: params.scope,
name: params.name,
version: parsed.version,
versions,
versions: versions.map(([version]) => version),
publishedAt: new Date(
(versions.find(([version]) => version === parsed.version)?.[1] ?? 0) * 1000
),
authors: parsed.authors?.map(parseAuthor),
description: parsed.description,
license: parsed.license,