diff --git a/pages/[...slug].vue b/pages/[...slug].vue index 05fb059..4408b10 100644 --- a/pages/[...slug].vue +++ b/pages/[...slug].vue @@ -54,9 +54,11 @@ const route = useRoute(); const loadedPaste: Ref = ref(); const currentPaste: Ref = ref(); +var pasteId: string|undefined; if (route.params.slug.length > 0) { - const { data } = await useFetch(`/api/pastes/${route.params.slug[0]}`); + pasteId = route.params.slug[0]; + const { data } = await useFetch(`/api/pastes/${pasteId}`); loadedPaste.value = data.value as Paste; } @@ -76,7 +78,7 @@ onMounted(async () => { // TODO Decode Error } } catch (e) { - decryptResolve({ content: getPlaceholderText(`${e}`), language: "markdown" }) + decryptResolve({ id: pasteId, content: getPlaceholderText(`${e}`), language: "markdown" }) } } else { // TODO No Key Provided @@ -84,7 +86,7 @@ onMounted(async () => { } } else { if (loadedPaste.value === null) { - decryptResolve({ content: getPlaceholderText("Error loading Paste!"), language: "markdown" }) + decryptResolve({ id: pasteId, content: getPlaceholderText("Error loading Paste!"), language: "markdown" }) } else { decryptResolve({ content: getPlaceholderText(), language: "markdown" }); } @@ -93,7 +95,6 @@ onMounted(async () => { function editorInited() { decryptPromise.then((paste) => { - console.log("Has paste", paste); currentPaste.value = paste; editorRef.value?.setSource(currentPaste.value.content); changeLanguage(currentPaste.value.language); diff --git a/pages/diff/[...slug].vue b/pages/diff/[...slug].vue index edad8e0..d1b2102 100644 --- a/pages/diff/[...slug].vue +++ b/pages/diff/[...slug].vue @@ -55,8 +55,10 @@ const route = useRoute(); const loadedPaste: Ref = ref(); const currentPaste: Ref = ref(); +var pasteId: string | undefined; if (route.params.slug.length > 0) { - const { data } = await useFetch(`/api/pastes/${route.params.slug[0]}`); + pasteId = route.params.slug[0]; + const { data } = await useFetch(`/api/pastes/${pasteId}`); loadedPaste.value = data.value as Paste; } @@ -76,7 +78,7 @@ onMounted(async () => { // TODO Decode Error } } catch (e) { - decryptResolve({ content: getPlaceholderText(`${e}`), language: "markdown" }) + decryptResolve({ id: pasteId, content: getPlaceholderText(`${e}`), language: "markdown" }) } } else { // TODO No Key Provided @@ -84,7 +86,7 @@ onMounted(async () => { } } else { if (loadedPaste.value === null) { - decryptResolve({ content: getPlaceholderText("Error loading Paste!"), language: "markdown" }) + decryptResolve({ id: pasteId, content: getPlaceholderText("Error loading Paste!"), language: "markdown" }) } else { decryptResolve({ content: getPlaceholderText(), language: "markdown" }); } @@ -109,7 +111,7 @@ async function saveFile() { // TODO no pasteLoaded return; } - const {original, modified} = editorRef.value!.getSource(); + const { original, modified } = editorRef.value!.getSource(); currentPaste.value.content = original; currentPaste.value.modified = modified; currentPaste.value.language = currentLanguage.value;