working on making nojs workable
This commit is contained in:
@@ -26,6 +26,9 @@ const getPostByTitle = query(
|
||||
"use server";
|
||||
const { ConnectionFactory, getUserID, getPrivilegeLevel } =
|
||||
await import("~/server/utils");
|
||||
const { parseConditionals, getSafeEnvVariables } =
|
||||
await import("~/server/conditional-parser");
|
||||
const { getFeatureFlags } = await import("~/server/feature-flags");
|
||||
const event = getRequestEvent()!;
|
||||
const privilegeLevel = await getPrivilegeLevel(event.nativeEvent);
|
||||
const userID = await getUserID(event.nativeEvent);
|
||||
@@ -78,6 +81,26 @@ const getPostByTitle = query(
|
||||
};
|
||||
}
|
||||
|
||||
// Build conditional evaluation context
|
||||
const conditionalContext = {
|
||||
isAuthenticated: userID !== null,
|
||||
privilegeLevel: privilegeLevel,
|
||||
userId: userID,
|
||||
currentDate: new Date(),
|
||||
featureFlags: getFeatureFlags(),
|
||||
env: getSafeEnvVariables()
|
||||
};
|
||||
|
||||
// Parse conditionals in post body
|
||||
if (post.body) {
|
||||
try {
|
||||
post.body = parseConditionals(post.body, conditionalContext);
|
||||
} catch (error) {
|
||||
console.error("Error parsing conditionals in post body:", error);
|
||||
// Fall back to showing original content
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch comments with sorting
|
||||
let commentQuery = "SELECT * FROM Comment WHERE post_id = ?";
|
||||
|
||||
@@ -274,10 +297,10 @@ export default function PostPage() {
|
||||
</div>
|
||||
|
||||
{/* Spacer to push content down */}
|
||||
<div class="h-80 sm:h-96 md:h-[50vh]"></div>
|
||||
<div class="-mt-[10vh] h-80 sm:h-96 md:h-[50vh]" />
|
||||
|
||||
{/* Content that slides over the fixed image */}
|
||||
<div class="bg-surface0 relative z-40 pb-24">
|
||||
<div class="bg-base relative z-40 pb-24">
|
||||
<div class="top-4 flex w-full flex-col justify-center md:absolute md:flex-row md:justify-between">
|
||||
<div class="">
|
||||
<div class="flex justify-center italic md:justify-start md:pl-24">
|
||||
@@ -287,7 +310,7 @@ export default function PostPage() {
|
||||
By Michael Freno
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex max-w-[420px] flex-wrap justify-center italic md:justify-start md:pl-24">
|
||||
<div class="flex max-w-105 flex-wrap justify-center italic md:justify-start md:pl-24">
|
||||
<For each={postData.tags as any[]}>
|
||||
{(tag) => (
|
||||
<div class="group relative m-1 h-fit w-fit rounded-xl bg-purple-600 px-2 py-1 text-sm">
|
||||
|
||||
@@ -336,14 +336,14 @@ export default function LoginPage() {
|
||||
<div class="relative pt-12 md:pt-24">
|
||||
{/* Error message */}
|
||||
<Show when={error()}>
|
||||
<div class="mb-4 w-full max-w-md rounded-lg border border-red-500 bg-red-500/10 px-4 py-3 text-center">
|
||||
<div class="border-maroon bg-red mb-4 w-full max-w-md rounded-lg border px-4 py-3 text-center">
|
||||
<Show when={error() === "passwordMismatch"}>
|
||||
<div class="text-lg font-semibold text-red-500">
|
||||
<div class="text-red text-lg font-semibold">
|
||||
Passwords did not match!
|
||||
</div>
|
||||
</Show>
|
||||
<Show when={error() === "duplicate"}>
|
||||
<div class="text-lg font-semibold text-red-500">
|
||||
<div class="text-red text-lg font-semibold">
|
||||
Email Already Exists!
|
||||
</div>
|
||||
</Show>
|
||||
@@ -354,7 +354,7 @@ export default function LoginPage() {
|
||||
error() !== "duplicate"
|
||||
}
|
||||
>
|
||||
<div class="text-sm text-red-500">{error()}</div>
|
||||
<div class="text-red text-sm">{error()}</div>
|
||||
</Show>
|
||||
</div>
|
||||
</Show>
|
||||
@@ -519,7 +519,7 @@ export default function LoginPage() {
|
||||
passwordConfRef.value.length >= 6
|
||||
? ""
|
||||
: "opacity-0 select-none"
|
||||
} text-center text-red-500 transition-opacity duration-200 ease-in-out`}
|
||||
} text-red text-center transition-opacity duration-200 ease-in-out`}
|
||||
>
|
||||
Passwords do not match!
|
||||
</div>
|
||||
@@ -535,11 +535,11 @@ export default function LoginPage() {
|
||||
<div
|
||||
class={`${
|
||||
showPasswordError()
|
||||
? "text-red-500"
|
||||
? "text-red"
|
||||
: showPasswordSuccess()
|
||||
? "text-green-500"
|
||||
? "text-green"
|
||||
: "opacity-0 select-none"
|
||||
} flex min-h-[16px] justify-center italic transition-opacity duration-300 ease-in-out`}
|
||||
} flex min-h-4 justify-center italic transition-opacity duration-300 ease-in-out`}
|
||||
>
|
||||
<Show when={showPasswordError()}>
|
||||
Credentials did not match any record
|
||||
@@ -576,7 +576,7 @@ export default function LoginPage() {
|
||||
initialRemainingTime={countDown()}
|
||||
size={48}
|
||||
strokeWidth={6}
|
||||
colors="#60a5fa"
|
||||
colors="var(--color-blue)"
|
||||
>
|
||||
{renderTime}
|
||||
</CountdownCircleTimer>
|
||||
|
||||
Reference in New Issue
Block a user