diff --git a/src/app.html b/src/app.html index 5e866b0..c241b90 100644 --- a/src/app.html +++ b/src/app.html @@ -3,8 +3,8 @@ Paste - - + + %sveltekit.head% + +
%sveltekit.body%
- - diff --git a/src/components/EditForm.svelte b/src/components/EditForm.svelte new file mode 100644 index 0000000..cc79ce7 --- /dev/null +++ b/src/components/EditForm.svelte @@ -0,0 +1,122 @@ + + +
+ {#if isUrlInputVisible} +
+ + + +
+ {:else} +
+
+ +
+ + + + + + + + + + +
+ {/if} +
+ + diff --git a/src/components/TopBar.svelte b/src/components/TopBar.svelte index 5c33941..ea94954 100644 --- a/src/components/TopBar.svelte +++ b/src/components/TopBar.svelte @@ -1,135 +1,17 @@ - -

Paste

- About + About + Source
- - {#if isUrlInputVisible} -
- - - -
- {:else} -
-
- -
- -
- -
-
- {/if} +
- - diff --git a/src/lib/utils.ts b/src/lib/utils.ts index c98e3d9..ec930ae 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -28,4 +28,8 @@ export const shorten = (name: string) => { return n.substr(0, 2) + n.substr(n.length - 2, 2) } +export function getLangFromUrl() { + return new URLSearchParams(window.location.search).get('l') ?? 'plt' +} + export const byId = (id: string) => document.getElementById(id) diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 9fa1502..19dc1f4 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -2,4 +2,4 @@ import '../app.postcss' - + \ No newline at end of file diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 52275bb..eb3a128 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -10,13 +10,16 @@ import rehypeStringify from 'rehype-stringify' import hljs from 'highlight.js' import 'highlight.js/styles/nord.min.css' + import TopBar from '../components/TopBar.svelte' + import Icon from '@iconify/svelte' + import { getLangFromUrl } from '$lib/utils' let decompressed: string let isMarkdown = false let isPlainText = false onMount(async () => { - let lang = new URLSearchParams(window.location.search).get('l') + let lang = getLangFromUrl() lang = lang === 'mrwn' || lang === 'gflm' ? 'md' : lang // back compatiblity with old links // extract the part in the url after the hash @@ -30,7 +33,7 @@ } // Markdown - if (lang === 'md' || lang === 'gflm') { + if (lang === 'md') { const html = await unified() .use(remarkParse) .use(remarkGfm) @@ -54,9 +57,18 @@ window.location.href = '/editor' } }) + + function getUrlDataPart(): string { + return window.location.search + window.location.hash + }
+ + + + +
{#if isMarkdown} {@html decompressed} diff --git a/src/routes/editor/+page.svelte b/src/routes/editor/+page.svelte index 1b5d74c..cf5681d 100644 --- a/src/routes/editor/+page.svelte +++ b/src/routes/editor/+page.svelte @@ -1,13 +1,12 @@ - + + + +
- + + +
@@ -98,13 +104,13 @@ ? '?' : Math.round(($shareUrl.length / charLen) * 100)}% of original)
-