Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions src/routes/articles/[slug]/edit/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
showFloatingWord = true;
} else if (e.key === "Escape") {
showFloatingWord = false;
} else if (e.key === " ") {
e.preventDefault(); // Prevent spaces
} else if (e.key === " " || e.code === "Space") {
e.preventDefault();
}
}

Expand All @@ -69,19 +69,21 @@
});

function handleMessage(data: any) {
if (data.type === "active_users_update") {
if (data?.type === "active_users_update" && data.data && typeof data.data.count === "number") {
$activeUsers = data.data.count;
}
}

function handleOpen() {
wsManager?.send({
type: "set_article",
article: {
id: data.article?.id,
slug: data.article?.slug,
},
});
if (wsManager?.send) {
wsManager.send({
type: "set_article",
article: {
id: article?.id,
slug: article?.slug,
},
});
}
}

function handleClose(event: CloseEvent) {
Expand Down Expand Up @@ -110,13 +112,13 @@
};
});

const summary =
article.content
?.split(":::")?.[2]
.slice(200)
.replace(/\*\*(.*?)\*\*/g, "$1")
.replace(/([*_])(.*?)\1/g, "$2")
.replace(/\[(.*?)\]\(.*?\)/g, "$1") + "...";
const summary = (() => {
const content = article?.content ?? "";
const parts = content.split(":::");
const raw = parts[2] ?? parts[0] ?? "";
const cleaned = raw.replace(/\*\*(.*?)\*\*/g, "$1").replace(/([*_])(.*?)\1/g, "$2").replace(/\[(.*?)\]\(.*?\)/g, "$1");
return cleaned.length > 200 ? cleaned.slice(0, 200) + "..." : cleaned;
})();
</script>

<svelte:head>
Expand Down Expand Up @@ -161,7 +163,8 @@
you may <a
href="https://discord.gg/cKWNV2uZUP"
class="text-primary hover:underline">appeal here</a
>. Note that banned accounts may also be restricted from the
>.
Note that banned accounts may also be restricted from the
Discord server.
</p>
<br />
Expand Down