diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index 87420dd..904b4ff 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -1,12 +1,18 @@
-
+ {#if umami_url && umami_site_id}
+
+ {/if}
diff --git a/src/routes/[slug]/+page.server.ts b/src/routes/[slug]/+page.server.ts
index b5cb51a..50da4e5 100644
--- a/src/routes/[slug]/+page.server.ts
+++ b/src/routes/[slug]/+page.server.ts
@@ -13,13 +13,18 @@ export const load: PageLoad = async ({ params }) => {
throw error(404, 'Paste not found');
}
+ const highlight = ext || paste.highlight;
+ const pasteUrl = `${env.SITE_URL}/${id}.${highlight}`;
+ const ogImageUrl = `${env.SITE_URL}/images/paste/${id}.${highlight}`;
+
// Build the response object
const response = {
id: paste.id,
- url: `${env.SITE_URL}/${id}.${paste.highlight}`,
+ pasteUrl,
+ ogImageUrl,
contents: paste.contents,
encrypted: paste.encrypted,
- highlight: ext || paste.highlight,
+ highlight: highlight,
burnAfterReading: paste.burnAfterReading,
}
diff --git a/src/routes/[slug]/+page.svelte b/src/routes/[slug]/+page.svelte
index 9d237d5..542da77 100644
--- a/src/routes/[slug]/+page.svelte
+++ b/src/routes/[slug]/+page.svelte
@@ -107,8 +107,8 @@
-
-
+
+
@@ -137,7 +137,7 @@
{/if}
SHARE
-
+
diff --git a/src/routes/images/paste/[id]/+server.ts b/src/routes/images/paste/[id]/+server.ts
deleted file mode 100644
index 7b5248c..0000000
--- a/src/routes/images/paste/[id]/+server.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-import { Mongo } from "$lib/db/index";
-import { env } from "$env/dynamic/private";
-import { error, type RequestHandler } from "@sveltejs/kit";
-
-export const GET: RequestHandler = async ({ params }) => {
- const { id } = params;
-
- const pastes = await Mongo.getNamedCollection("pastes");
- const paste = await pastes.findOne({ id });
-
- if (!paste) {
- throw error(404, 'Paste not found');
- }
-
- if (paste.encrypted) {
- throw error(404, 'Cannot generate image for encrypted paste');
- }
-
- if (paste.burnAfterReading) {
- throw error(404, 'Cannot generate image for burnable paste');
- }
-
- const code = paste.contents;
-
- // Grab at most 15 lines of the paste, if there aren't 15 lines, pad the rest with empty strings.
- let lines = code.split('\n').slice(0, 15).concat(Array.from({ length: 15 - code.split('\n').length }, () => ''));
-
- // Truncate each line to 80 characters, and pad the rest with spaces.
- lines = lines.map(line => line.slice(0, 70).padEnd(70, ' '));
-
- const title = `${env.SITE_URL}/${id}.${paste.highlight}`;
- const url = `https://inkify.0x45.st/generate?code=${encodeURIComponent(lines.join('\n'))}&window_title=${encodeURIComponent(title)}&language=${encodeURIComponent(paste.highlight)}&pad_horiz=5&pad_vert=5`;
-
- const res = await fetch(url);
- const image = res.body;
-
- if (image) {
- return new Response(image, {
- headers: {
- 'Content-Type': 'image/png',
- 'Cache-Control': 'public, max-age=604800, immutable',
- },
- });
- } else {
- throw error(500, 'Could not generate image');
- }
-};
\ No newline at end of file