2022-05-10 14:01:07 +00:00
|
|
|
<script lang="ts">
|
2022-05-10 22:38:41 +00:00
|
|
|
import Highlight from "svelte-highlight";
|
|
|
|
import highlightStyle from "svelte-highlight/styles/vs2015";
|
|
|
|
import getLangFromShare from "./getLangFromShare";
|
|
|
|
|
2022-05-10 20:37:30 +00:00
|
|
|
export let contentType: string;
|
|
|
|
export let filename: string;
|
|
|
|
export let slug: string;
|
2022-05-10 14:01:07 +00:00
|
|
|
|
2022-05-10 22:38:41 +00:00
|
|
|
async function loadShare() {
|
2022-05-10 20:37:30 +00:00
|
|
|
const res = await fetch(`/s/${slug}`);
|
2022-05-10 22:38:41 +00:00
|
|
|
return await res.text();
|
|
|
|
}
|
|
|
|
|
|
|
|
async function loadLang() {
|
|
|
|
return await getLangFromShare(contentType,filename).then(v => v.default);
|
|
|
|
}
|
2022-05-10 14:01:07 +00:00
|
|
|
</script>
|
|
|
|
|
2022-05-10 22:38:41 +00:00
|
|
|
|
|
|
|
<svelte:head>
|
|
|
|
{@html highlightStyle}
|
|
|
|
</svelte:head>
|
|
|
|
|
2022-05-10 21:19:31 +00:00
|
|
|
<div class="container" >
|
|
|
|
<header>{filename}</header>
|
2022-05-10 22:38:41 +00:00
|
|
|
|
|
|
|
{#await Promise.all([loadShare(), loadLang()])}
|
|
|
|
Loading...
|
|
|
|
{:then v}
|
|
|
|
<Highlight language={v[1]} code={v[0]} />
|
|
|
|
{/await}
|
2022-05-10 14:01:07 +00:00
|
|
|
</div>
|
2022-05-10 21:19:31 +00:00
|
|
|
|
|
|
|
<style>
|
|
|
|
header{
|
|
|
|
font-size: 1.5rem;
|
|
|
|
font-weight: bold;
|
|
|
|
margin-bottom: 1rem;
|
|
|
|
color: #58a6ff;
|
|
|
|
border-bottom: solid 1px #1f6feb;
|
|
|
|
|
|
|
|
padding: 1rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.container{
|
|
|
|
border-width: 2px;
|
|
|
|
border-color: #1f6feb;
|
|
|
|
border-style: solid;
|
|
|
|
border-radius: 5px;
|
2022-05-11 17:58:04 +00:00
|
|
|
min-width: 50rem;
|
2022-05-10 21:19:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|