Skip to content

Commit

Permalink
feat: 优化样式、管理页添加文件菜单
Browse files Browse the repository at this point in the history
  • Loading branch information
huayemao committed Jun 2, 2024
1 parent e29bc48 commit e21a62f
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 36 deletions.
2 changes: 1 addition & 1 deletion app/(content)/upload/page.tsx → app/admin/files/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default async function UploadTest() {
))}

<form
action="/api/upload"
action="/api/files"
encType="multipart/form-data"
method="POST"
className="w-96 rounded bg-white p-8 mx-auto space-y-4"
Expand Down
3 changes: 1 addition & 2 deletions app/api/upload/route.ts → app/api/files/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ export async function POST(request: Request) {
});
}

// Process the webhook payload
} catch (error) {
return new Response(`Webhook error: ${error.message}`, {
return new Response(`error: ${error.message}`, {
status: 400,
});
}
Expand Down
5 changes: 5 additions & 0 deletions components/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ export function Menu() {
href: "/admin/tags",
iconName: "Tag",
},
{
title: "文件管理",
href: "/admin/files",
iconName: "File",
},
{
title: "设置",
href: "/admin/settings",
Expand Down
21 changes: 8 additions & 13 deletions components/Post/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { markdownExcerpt } from "@/lib/utils";
import huayemao from "@/public/img/huayemao.svg";
import c from "@/styles/post.module.css";
import "katex/dist/katex.min.css";
import { Edit } from "lucide-react";
import dynamic from "next/dynamic";
import { join } from "path";
import { BackButton } from "../BackButton";
Expand Down Expand Up @@ -53,12 +54,6 @@ export default async function Post({ data: post, recentPosts: posts }: Props) {
<div className="w-full md:px-10 text-xl text-muted-800 leading-normal">
<div className="flex justify-between w-full mb-5 print:hidden">
<BackButton />
<a
href={`/admin/posts/${post.id}`}
className="mr-4 md:mr-8 font-medium text-base text-muted-400 hover:text-primary-500 transition-colors duration-300"
>
编辑
</a>
</div>
<article
className={
Expand All @@ -74,19 +69,19 @@ export default async function Post({ data: post, recentPosts: posts }: Props) {
<div className="w-full ptablet:w-3/4 ltablet:w-1/3 lg:w-1/4 ptablet:mx-auto print:hidden">
<div className="mt-10">
<div>
<h2
className="font-heading text-muted-800 dark:text-white font-semibold text-xl mb-6
"
>
分享文章
</h2>

<div className="flex gap-4">
<ShareButton
options={{
title: post.title,
}}
/>
<a
href={`/admin/posts/${post.id}`}
className="flex-1 inline-flex justify-center items-center py-4 px-5 rounded bg-muted-200 dark:bg-muted-700 hover:bg-muted-100 dark:hover:bg-muted-600 text-muted-600 dark:text-muted-400 transition-colors duration-300 cursor-pointer tw-accessibility
"
>
<Edit className="w-4 h-4 " fill="currentColor" />
</a>
</div>
</div>
<hr className="my-10 border-t border-muted-200 dark:border-muted-800" />
Expand Down
45 changes: 25 additions & 20 deletions components/Post/toc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,38 @@ export default function TOC() {
}
});

const headings = observedElements().filter((e) =>
e.tagName.toLowerCase().match(/^h\d$/)
);

return (
<section className="my-6 sticky top-24">
<header>
<h2 className="font-heading text-muted-800 dark:text-white font-semibold text-xl mb-6">
文章目录
</h2>
</header>
{headings.length ? (
<header>
<h2 className="font-heading text-muted-800 dark:text-white font-semibold text-xl mb-6">
文章目录
</h2>
</header>
) : null}

<ul
key={window.location.pathname}
className="max-h-[calc(100vh_-_168px)] overflow-y-auto"
style={{ scrollbarWidth: "thin" }}
>
{observedElements()
.filter((e) => e.tagName.toLowerCase().match(/^h\d$/))
.map((item) => {
const id = item.id;
return (
<TOCItem
key={id}
id={id}
text={item.textContent as string}
level={parseInt(item.tagName.slice(1))}
// sub={item.sub}
currentViewedTocItem={currentViewedTocItem}
/>
);
})}
{headings.map((item) => {
const id = item.id;
return (
<TOCItem
key={id}
id={id}
text={item.textContent as string}
level={parseInt(item.tagName.slice(1))}
// sub={item.sub}
currentViewedTocItem={currentViewedTocItem}
/>
);
})}
</ul>
</section>
);
Expand Down

0 comments on commit e21a62f

Please sign in to comment.