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

View File

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

View File

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