From 36ac48ac36df6f8f2dd61af93d879c8cb116f96b Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Thu, 28 Aug 2025 14:10:16 -0400 Subject: [PATCH] And now you can view a post. --- static/js/code.js | 11 +++++++++++ views/post/view.html | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/static/js/code.js b/static/js/code.js index 4115938..f6ccf53 100644 --- a/static/js/code.js +++ b/static/js/code.js @@ -79,3 +79,14 @@ const ConfirmDelete = async (table, obj_id) => { return false; } } + +const UrlId = () => { + let url = new URL(window.location.href); + let parts = url.pathname.split("/"); + + if(window.location.href.endsWith("/")) { + return parts[parts.length - 2]; + } else { + return parts[parts.length - 1]; + } +} diff --git a/views/post/view.html b/views/post/view.html index e8bcbf5..f72007e 100644 --- a/views/post/view.html +++ b/views/post/view.html @@ -1,7 +1,7 @@ + x-init="item = await GetJson('/api/message/' + UrlId())">