This commit is contained in:
Jason Schwarzenberger 2020-12-02 14:14:31 +13:00
parent 888c341296
commit f524ecec7b
2 changed files with 18 additions and 7 deletions

View File

@ -70,7 +70,11 @@
<article class="article">
<header class="article-header">
<h1 class="article-title">
{#if !title}
{story.title}
{:else}
{@html title}
{/if}
</h1>
{#if story.url}
<div>source: <a class="article-source" href={story.url}>{host}</a></div>
@ -81,6 +85,10 @@
</header>
<section class="article-body">
{#if !html}
{story.content}
{:else}
{@html html}
{/if}
</section>
</article>

View File

@ -6,7 +6,7 @@
export let stories;
const host = (url) => new URL(url).hostname.replace(/^www\./, "");
let purify = () => "";
let purify;
onMount(() => {
purify = (html) => DOMPurify.sanitize(html);
@ -48,10 +48,13 @@
alt="logo"
class="story-icon"
style="height: 1rem; width: 1rem;" />
<a
class="story-title"
rel="prefetch"
href="/{story.id}">{@html purify(story.title)}</a>
<a class="story-title" rel="prefetch" href="/{story.id}">
{#if !purify}
{story.title}
{:else}
{@html purify(story.title)}
{/if}
</a>
<a
class="story-source"
href={story.url || story.link}>{host(story.url || story.link)}</a>