Files
archtika/web-app/src/lib/components/WebsiteEditor.svelte

71 lines
1.3 KiB
Svelte
Raw Normal View History

2024-08-01 18:09:35 +02:00
<script lang="ts">
import type { Snippet } from "svelte";
2024-08-03 13:49:41 +02:00
import markdownit from "markdown-it";
import hljs from "highlight.js";
2024-08-01 18:09:35 +02:00
const { id, title, children, previewContent } = $props<{
id: string;
title: string;
children: Snippet;
previewContent: string;
}>();
2024-08-03 13:49:41 +02:00
const md = markdownit({
linkify: true,
typographer: true,
highlight: (str, lang) => {
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(str, { language: lang }).value;
} catch (_) {}
}
return "";
}
});
2024-08-01 18:09:35 +02:00
</script>
<div class="operations">
<h1>{title}</h1>
2024-08-02 15:33:18 +02:00
<nav class="operations__nav">
2024-08-01 18:09:35 +02:00
<a href="/website/{id}">Settings</a>
<a href="/website/{id}/articles">Articles</a>
2024-08-02 15:33:18 +02:00
</nav>
2024-08-01 18:09:35 +02:00
{@render children()}
</div>
<div class="preview">
2024-08-03 13:49:41 +02:00
{@html md.render(previewContent)}
2024-08-01 18:09:35 +02:00
</div>
<style>
.operations,
.preview {
padding: 1rem;
2024-08-03 13:49:41 +02:00
overflow-y: auto;
2024-08-01 18:09:35 +02:00
}
.operations {
2024-08-02 15:33:18 +02:00
border-inline-end: var(--border-primary);
2024-08-01 18:09:35 +02:00
}
2024-08-02 15:33:18 +02:00
.operations__nav {
margin-block: 1rem 2rem;
}
.operations__nav > a {
display: inline-block;
padding-inline: 0.5rem;
padding-block: 0.25rem;
overflow-x: auto;
}
2024-08-01 18:09:35 +02:00
.preview {
2024-08-03 13:49:41 +02:00
display: flex;
flex-direction: column;
gap: 1rem;
2024-08-01 18:09:35 +02:00
}
</style>