Skip to content

Commit

Permalink
svelte: Only render after component is mounted
Browse files Browse the repository at this point in the history
  • Loading branch information
laymonage committed May 14, 2022
1 parent 2e55457 commit ec31d7e
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions svelte/src/lib/Giscus.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
Theme,
} from '.';
onMount(() => import('giscus'));
export let id: string = undefined;
export let repo: `${string}/${string}`;
export let repoId: string;
Expand All @@ -24,20 +22,29 @@
export let theme: Theme = 'light';
export let lang: AvailableLanguage = 'en';
export let loading: Loading = 'eager';
let mounted = false;
onMount(() => {
mounted = true;
import('giscus');
});
</script>

<giscus-widget
{id}
{repo}
repoid={repoId}
{category}
categoryid={categoryId}
{mapping}
{term}
reactionsenabled={reactionsEnabled}
emitmetadata={emitMetadata}
inputposition={inputPosition}
{theme}
{lang}
{loading}
/>
{#if mounted}
<giscus-widget
{id}
{repo}
repoid={repoId}
{category}
categoryid={categoryId}
{mapping}
{term}
reactionsenabled={reactionsEnabled}
emitmetadata={emitMetadata}
inputposition={inputPosition}
{theme}
{lang}
{loading}
/>
{/if}

0 comments on commit ec31d7e

Please sign in to comment.