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

View file

@ -113,7 +113,10 @@ export const load: PageLoad = async ({ params, fetch }) => {
scope: params.scope, scope: params.scope,
name: params.name, name: params.name,
version: parsed.version, 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), authors: parsed.authors?.map(parseAuthor),
description: parsed.description, description: parsed.description,
license: parsed.license, license: parsed.license,