Async import of brotli

This commit is contained in:
Simon Cambier 2023-11-24 19:00:49 +01:00
parent 0f9faa45f0
commit ad4b21daf1

View File

@ -1,6 +1,5 @@
<script lang="ts">
import { onMount } from 'svelte'
import * as brotli from '$lib/brotli'
import * as lzma from '$lib/lzma'
import { unified } from 'unified'
import remarkParse from 'remark-parse'
@ -12,7 +11,7 @@
import 'highlight.js/styles/nord.min.css'
import TopBar from '../components/TopBar.svelte'
import Icon from '@iconify/svelte'
import { getLangFromUrl } from '$lib/utils'
import { getLangFromUrl } from '$lib/utils'
let decompressed: string
let isMarkdown = false
@ -29,7 +28,8 @@
if (hash.startsWith('XQAAA')) {
decompressed = await lzma.decompress(hash)
} else {
decompressed = await brotli.decompress(hash)
const brotli = import('$lib/brotli')
decompressed = await (await brotli).decompress(hash)
}
// Markdown
@ -65,7 +65,11 @@
<div>
<TopBar>
<a href={'/editor' + getUrlDataPart()} class="p-1 hover:bg-gray-600/50" title="Edit a copy of this note">
<a
href={'/editor' + getUrlDataPart()}
class="p-1 hover:bg-gray-600/50"
title="Edit a copy of this note"
>
<Icon class="text-xl" icon="fluent:document-edit-16-regular" />
</a>
</TopBar>