Skip to content

Commit

Permalink
feat: provider
Browse files Browse the repository at this point in the history
  • Loading branch information
AbigailDeng authored and AbigailDeng committed Jul 25, 2024
2 parents 3434bbb + 1e2525c commit e323e49
Show file tree
Hide file tree
Showing 22 changed files with 109 additions and 328 deletions.
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM cgr.dev/chainguard/nginx:latest

WORKDIR /usr/share/nginx/html
COPY out .

EXPOSE 8080
25 changes: 0 additions & 25 deletions app/admin/page.tsx

This file was deleted.

30 changes: 0 additions & 30 deletions app/api/revalidate/route.ts

This file was deleted.

13 changes: 6 additions & 7 deletions app/api/search/route.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { getSearchConfig } from "@/services/get-search-config";
import { NextRequest } from "next/server";

export async function GET(request: NextRequest) {
const config = await getSearchConfig();

return Response.json(config);
export async function GET() {
return Response.json({
index: "index",
host: "host",
apikey: "apikey",
});
}
96 changes: 0 additions & 96 deletions app/api/token/route.ts

This file was deleted.

2 changes: 2 additions & 0 deletions app/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import { Skeleton } from "@/components/ui/skeleton";
import { Desktop } from "../components/provider";

Expand Down
24 changes: 0 additions & 24 deletions app/node/[id]/page.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import Link from "next/link";

export default function NotFound() {
return (
<div className="flex items-center justify-center h-[calc(100vh-241px)] w-full bg-gray-100 mb-4">
Expand Down
31 changes: 0 additions & 31 deletions app/redirect/page.tsx

This file was deleted.

3 changes: 2 additions & 1 deletion app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SITE_URL } from "@/environment";
import { getChildNodes } from "@/services/get-child-nodes";
import { getPath } from "@/services/get-path";
import { getTopLevelNodes } from "@/services/get-top-level-nodes";
Expand All @@ -17,7 +18,7 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
if (nodes) {
for (const node of nodes) {
map.push({
url: `${process.env.SITE_URL}${await getPath(node.node_token)}`,
url: `https://${SITE_URL()}${await getPath(node.node_token)}`,
lastModified: new Date(Number(node.obj_edit_time) * 1000),
changeFrequency: "weekly",
priority: 0.5,
Expand Down
71 changes: 3 additions & 68 deletions app/wiki/[...id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Renderer, { AnyItem } from "@/components/blocks/renderer";
import GithubSlugger from "github-slugger";
import { redirect } from "next/navigation";
import TableOfContents from "@/components/blocks/table-of-contents";
import {
findPathByTitles,
formatStringArray,
Expand All @@ -11,15 +10,9 @@ import {
import { PrevNext } from "@/components/prev-next";
import { getNode } from "@/services/get-node";
import { getDocBlocks } from "@/services/get-doc-blocks";
import { revalidateTag } from "next/cache";
import { FormLoading } from "@/components/form-loading";
import { DateModified } from "@/components/date-modified";
import { Admin } from "@/components/admin";
import { NodesData } from "@/services/larkServices";
import { headers } from "next/headers";
import { isMobile } from "../../../lib/isMobile";
import { Collapse, ConfigProvider } from "antd";
import { Desktop, Mobile } from "../../../components/provider";
import { Aside } from "@/components/aside";
interface Props {
params: {
id: string[];
Expand Down Expand Up @@ -47,31 +40,10 @@ export default async function Document({ params }: Props) {
if (!id) {
redirect("/404");
}
const { data, docx_token, edit_time } = await getData(id!);
const { data, edit_time } = await getData(id!);

const slugger = new GithubSlugger();

async function invalidatePage(formData: FormData) {
"use server";

const id = formData.get("id");
if (typeof id === "string") revalidateTag(id);

const docx_token = formData.get("docx_token");
if (typeof docx_token === "string") revalidateTag(docx_token);

console.log("revalidating", id, docx_token);
}
const contentItems = [
{
key: "1",
label: "On this page",
children: <TableOfContents allItems={data} />,
},
];
const ifShowCollapse = data.filter(i =>
[3, 4, 5, 6, 7, 8, 9, 10, 11].includes(i.block_type)
).length;
return (
<main className="flex flex-col-reverse sm:flex-row">
<div className="sm:w-2/3 w-full">
Expand All @@ -85,45 +57,8 @@ export default async function Document({ params }: Props) {
))}
<PrevNext />
<DateModified date={new Date(Number(edit_time) * 1000)} />
<Admin>
<form action={invalidatePage}>
<input name="id" type="hidden" value={id} />
<input name="docx_token" type="hidden" value={docx_token} />
<FormLoading className="bg-red-700 text-white rounded-sm p-2 mb-8 inline-block">
invalidate page
</FormLoading>
</form>
</Admin>
</div>
<aside className="sm:w-1/3 w-full">
<Mobile>
{ifShowCollapse ? (
<ConfigProvider
theme={{
token: {
colorLink: "#000",
fontFamily: "inherit",
},
components: {
Collapse: {
contentPadding: "2px",
},
},
}}
>
<Collapse
className="wiki-collapse-container !mb-4"
items={contentItems}
></Collapse>
</ConfigProvider>
) : null}
</Mobile>
<Desktop>
<div className="overflow-y-auto max-h-[calc(100vh-60px)] sticky top-20">
<TableOfContents allItems={data} />
</div>
</Desktop>
</aside>
<Aside data={data} />
</main>
);
}
Expand Down
4 changes: 1 addition & 3 deletions components/blocks/child-pages.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"use server";

import { key } from "@/lib/utils";
import { Item } from "./common";
import { getChildNodes } from "@/services/get-child-nodes";
Expand Down Expand Up @@ -48,7 +46,7 @@ export async function ChildPages(props: ChildPages) {
const data = await getData(props.wiki_catalog.wiki_token);
return (
<div className="grid lg:grid-cols-2 gap-2 my-8">
{data.map(i => (
{data.map((i) => (
<Link key={key()} href={i.href}>
<Card className="hover:border-black h-full">
<CardHeader>
Expand Down
Loading

0 comments on commit e323e49

Please sign in to comment.