More embed options available

This commit is contained in:
LittleSheep 2024-02-10 01:53:57 +08:00
parent c7d250d201
commit a223c85ed1
3 changed files with 81 additions and 66 deletions

View File

@ -10,6 +10,7 @@ export default function PostItem(props: {
noAuthor?: boolean, noAuthor?: boolean,
noControl?: boolean, noControl?: boolean,
noRelated?: boolean, noRelated?: boolean,
noContent?: boolean,
onRepost?: (post: any) => void, onRepost?: (post: any) => void,
onReply?: (post: any) => void, onReply?: (post: any) => void,
onEdit?: (post: any) => void, onEdit?: (post: any) => void,
@ -63,9 +64,10 @@ export default function PostItem(props: {
</div> </div>
</a> </a>
</Show> </Show>
<Show when={!props.noContent}>
<div class="px-7 py-5"> <div class="px-7 py-5">
<h2 class="card-title">{props.post.title}</h2> <h2 class="card-title">{props.post.title}</h2>
<Show when={!props.noClick} fallback={content}> <Show when={!props.noClick} fallback={content}>
<a href={`/posts/${props.post.id}`}> <a href={`/posts/${props.post.id}`}>
{content} {content}
@ -126,6 +128,8 @@ export default function PostItem(props: {
</div> </div>
</Show> </Show>
</div> </div>
</Show>
<Show when={!props.noControl}> <Show when={!props.noControl}>
<div class="relative"> <div class="relative">
<Show when={!userinfo?.isLoggedIn}> <Show when={!userinfo?.isLoggedIn}>

View File

@ -35,7 +35,7 @@ export default function RootLayout(props: any) {
} }
const mainContentStyles = createMemo(() => { const mainContentStyles = createMemo(() => {
if (!searchParams["noTitle"]) { if (!searchParams["embedded"]) {
return "h-[calc(100vh-64px)] mt-[64px]"; return "h-[calc(100vh-64px)] mt-[64px]";
} else { } else {
return "h-[100vh]"; return "h-[100vh]";
@ -50,7 +50,7 @@ export default function RootLayout(props: any) {
</div> </div>
</div> </div>
}> }>
<Show when={!searchParams["noTitle"]}> <Show when={!searchParams["embedded"]}>
<Navbar /> <Navbar />
</Show> </Show>

View File

@ -1,5 +1,5 @@
import { createSignal, Show } from "solid-js"; import { createSignal, Show } from "solid-js";
import { useNavigate, useParams } from "@solidjs/router"; import { useNavigate, useParams, useSearchParams } from "@solidjs/router";
import { createStore } from "solid-js/store"; import { createStore } from "solid-js/store";
import { closeModel, openModel } from "../scripts/modals.ts"; import { closeModel, openModel } from "../scripts/modals.ts";
import PostPublish from "../components/PostPublish.tsx"; import PostPublish from "../components/PostPublish.tsx";
@ -17,6 +17,8 @@ export default function PostPage() {
const params = useParams(); const params = useParams();
const navigate = useNavigate(); const navigate = useNavigate();
const [searchParams] = useSearchParams();
async function readPost(pn?: number) { async function readPost(pn?: number) {
if (pn) setPage(pn); if (pn) setPage(pn);
const res = await fetch(`/api/posts/${params["postId"]}?` + new URLSearchParams({ const res = await fetch(`/api/posts/${params["postId"]}?` + new URLSearchParams({
@ -96,11 +98,17 @@ export default function PostPage() {
</div> </div>
<div class="flex pt-1"> <div class="flex pt-1">
<Show when={searchParams["embedded"]} fallback={
<button class="btn btn-ghost ml-[20px] w-12 h-12" onClick={() => back()}> <button class="btn btn-ghost ml-[20px] w-12 h-12" onClick={() => back()}>
<i class="fa-solid fa-angle-left"></i> <i class="fa-solid fa-angle-left"></i>
</button> </button>
}>
<div class="w-12 h-12 ml-[20px] flex justify-center items-center">
<i class="fa-solid fa-comments mb-1"></i>
</div>
</Show>
<div class="px-5 flex items-center"> <div class="px-5 flex items-center">
<p>Post #{info()?.id}</p> <p>{searchParams["title"] ?? "Post details"}</p>
</div> </div>
</div> </div>
@ -129,6 +137,9 @@ export default function PostPage() {
onError={setError} onError={setError}
onReact={readPost} onReact={readPost}
onDelete={deletePost} onDelete={deletePost}
noAuthor={searchParams["noAuthor"] != null}
noContent={searchParams["noContent"] != null}
noControl={searchParams["noControl"] != null}
onRepost={(item) => setMeta(item, "reposting")} onRepost={(item) => setMeta(item, "reposting")}
onReply={(item) => setMeta(item, "replying")} onReply={(item) => setMeta(item, "replying")}
onEdit={(item) => setMeta(item, "editing")} onEdit={(item) => setMeta(item, "editing")}