+
+ Report a Problem
+
+ Please describe the problem you're experiencing. We'll look into it as soon as
+ possible.
+
+
+
+
+
+
Problem Type
+
+
+
+ UI problem
+
+
+
+ Article is not full
+
+
+
+ Suggestion
+
+
+
+ Vulnerability (XSS, etc.)
+
+
+
+ Other
+
+
+
+
+
Problem Description
+
+
+ The current opened page will be automatically attached to your report.
+
+
-
-
Problem Description
-
-
- The current opened page will be automatically attached to your report.
-
+
+
+ Cancel
+
-
-
- Cancel
-
-
-
diff --git a/new-web/src/routes/+layout.svelte b/new-web/src/routes/+layout.svelte
index 068c471..d4621ed 100644
--- a/new-web/src/routes/+layout.svelte
+++ b/new-web/src/routes/+layout.svelte
@@ -1,7 +1,9 @@
+
diff --git a/new-web/src/routes/[slug]/+page.server.js b/new-web/src/routes/[slug]/+page.server.js
index 586c006..b4300f2 100644
--- a/new-web/src/routes/[slug]/+page.server.js
+++ b/new-web/src/routes/[slug]/+page.server.js
@@ -27,6 +27,16 @@ const CODE_ATTRIBUTES = {
"data-ms-editor": "false",
};
+let highlighterInstance = null;
+
+async function getHighlighter() {
+ if (!highlighterInstance) {
+ highlighterInstance = await createHighlighter(HIGHLIGHT_CONFIG);
+ await highlighterInstance.loadLanguage("javascript", "typescript");
+ }
+ return highlighterInstance;
+}
+
const MOCK_ARTICLE = {
title: "UploadThing is 5x Faster",
date: "2024-09-13T12:00:00Z",
@@ -75,8 +85,7 @@ function createCodeCopyButton(code, toggleMs = 3000) {
}
async function createHighlightedCode(code, lang = "text") {
- const highlighter = await createHighlighter(HIGHLIGHT_CONFIG);
- await highlighter.loadLanguage("javascript", "typescript");
+ const highlighter = await getHighlighter();
const lightHtml = highlighter.codeToHtml(code, {
lang,
@@ -115,9 +124,36 @@ async function createHighlightedCode(code, lang = "text") {
`;
}
+const ErrorCodes = {
+ ARTICLE_NOT_FOUND: "ARTICLE_NOT_FOUND",
+ RENDER_ERROR: "RENDER_ERROR",
+ COMPILE_ERROR: "COMPILE_ERROR",
+ INTERNAL_ERROR: "INTERNAL_ERROR",
+};
+
export async function load({ params }) {
+ let transformed = null;
+ try {
+ transformed = await render("medium");
+ } catch (err) {
+ console.error("Failed to render article:", err);
+ }
+
+ if (!transformed) {
+ return {
+ slug: params.slug,
+ loading: false,
+ content: null,
+ article: null,
+ error: {
+ status: 404,
+ message: "Article not found",
+ code: ErrorCodes.ARTICLE_NOT_FOUND,
+ },
+ };
+ }
+
try {
- const transformed = await render("medium");
const { code } = await compile(transformed.text, {
highlight: {
highlighter: createHighlightedCode,
@@ -129,21 +165,23 @@ export async function load({ params }) {
loading: false,
content: code,
article: MOCK_ARTICLE,
+ error: null,
};
- } catch (error) {
- console.error("Failed to load article:", error);
+ } catch (compileError) {
return {
slug: params.slug,
loading: false,
content: null,
- article: {
- title: "Article Not Found",
- date: new Date().toISOString(),
- author: { name: "Unknown", role: "", avatar: "" },
- postImage: null,
- tableOfContents: [],
+ article: null,
+ error: {
+ status: 500,
+ message: "Failed to compile article content",
+ code: ErrorCodes.COMPILE_ERROR,
+ details:
+ process.env.NODE_ENV === "development"
+ ? compileError.message
+ : undefined,
},
- error: error.message,
};
}
}
diff --git a/tests/smokie_tests.py b/tests/smokie_tests.py
index de8f832..f979758 100644
--- a/tests/smokie_tests.py
+++ b/tests/smokie_tests.py
@@ -23,7 +23,7 @@ url_for_test = {
"https://www.freedium.cfd/c81e00f6320d",
}
-blacklist_url = {"51e23c5a2aac"}
+blacklist_url = {"51e23c5a2aac", "e65e737baa29"}
def main():