BLOG-72 Fix img cannot be shown on content page (#74)
All checks were successful
Frontend CI / build (push) Successful in 1m7s

### Description

<https://www.npmjs.com/package/sanitize-html>

![image.png](/attachments/f35293b6-7c80-4a6f-917e-fa0d4cffa804)

### Package Changes

_No response_

### Screenshots

_No response_

### Reference

Resolves #72

### Checklist

- [x] A milestone is set
- [x] The related issuse has been linked to this branch

Reviewed-on: #74
Co-authored-by: SquidSpirit <squid@squidspirit.com>
Co-committed-by: SquidSpirit <squid@squidspirit.com>
This commit is contained in:
SquidSpirit 2025-07-26 00:33:17 +08:00 committed by squid
parent 2039edf5e9
commit 7770a5b569

View File

@ -5,7 +5,9 @@
const { html }: { html: string } = $props(); const { html }: { html: string } = $props();
const sanitizedHtml = $derived(sanitizeHtml(html)); const sanitizedHtml = $derived(
sanitizeHtml(html, { allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img']) })
);
</script> </script>
{@html sanitizedHtml} {@html sanitizedHtml}