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

View File

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