diff --git a/components/MarkdownRenderer.tsx b/components/MarkdownRenderer.tsx index 3fa3523..6742fb0 100644 --- a/components/MarkdownRenderer.tsx +++ b/components/MarkdownRenderer.tsx @@ -6,16 +6,24 @@ export function MarkdownRenderer(props: { text: string | undefined }) { text = ""; } let c = text; + let meta = null; if (text.startsWith("---")) { const index = text.indexOf("\n---", 3); + meta = text.slice(4, index); c = text.slice(index + 4, text.length); } - return ( + return (<> + {meta ?
+

Meta

+
{meta}
+
+
:
}
+ >
+ ); } diff --git a/islands/ContentRenderer.tsx b/islands/ContentRenderer.tsx index adaade2..e2a697b 100644 --- a/islands/ContentRenderer.tsx +++ b/islands/ContentRenderer.tsx @@ -50,7 +50,7 @@ function FetchAndRender(props: { src: string; type: string }) { } } -export function RenderView(props: { src: string }) { +export function RenderView(props: { src: string, mdbase?: string }) { const src = props.src; const type = extToType(extname(src)); switch (type) { diff --git a/main.ts b/main.ts index b83fee4..fdaf5b5 100644 --- a/main.ts +++ b/main.ts @@ -6,8 +6,6 @@ import { Manifest, - Plugin, - PluginRenderResult, ServerContext, StartOptions, } from "$fresh/server.ts"; @@ -18,7 +16,6 @@ import twindConfig from "./twind.config.ts"; import "https://deno.land/std@0.170.0/dotenv/load.ts"; import { Command } from "https://deno.land/x/cliffy@v0.25.6/mod.ts"; -import { fromFileUrl, join } from "path/mod.ts"; import { prepareSecretKey } from "./util/secret.ts"; import { serve } from "http/server.ts"; @@ -28,21 +25,6 @@ import { prepareDocs } from "./src/store/doc.ts"; import { connectDB } from "./src/user/db.ts"; import * as users from "./src/user/user.ts"; -const github_markdown = (await Deno.readTextFile( - join(fromFileUrl(import.meta.url), "..", "static", "github-markdown.css"), -)).replaceAll("\n", ""); - -const CSSPlugin: Plugin = { - name: "css plugin", - render(ctx): PluginRenderResult { - ctx.render(); - return { - styles: [{ - cssText: github_markdown, - }], - }; - }, -}; async function startServer(manifest: Manifest, options: StartOptions = {}) { const ctx = await ServerContext.fromManifest(manifest, options); @@ -63,7 +45,7 @@ async function start( } = {}, ) { await startServer(manifest, { - plugins: [twindPlugin(twindConfig), CSSPlugin], + plugins: [twindPlugin(twindConfig)], port: port, hostname: hostname, }); diff --git a/routes/_middleware.ts b/routes/_middleware.ts index 63c7eb5..d06f9df 100644 --- a/routes/_middleware.ts +++ b/routes/_middleware.ts @@ -7,6 +7,7 @@ export const handler = async ( req: Request, ctx: MiddlewareHandlerContext>, ) => { + const secret_key = await prepareSecretKey(); const cookies = getCookies(req.headers); const jwt = cookies["auth"]; diff --git a/routes/dir/[...path].tsx b/routes/dir/[...path].tsx index 93f4642..d952776 100644 --- a/routes/dir/[...path].tsx +++ b/routes/dir/[...path].tsx @@ -1,5 +1,5 @@ import { HandlerContext, Handlers, PageProps } from "$fresh/server.ts"; -import { Head } from "$fresh/runtime.ts"; +import { asset, Head } from "$fresh/runtime.ts"; import { decodePath, encodePath, @@ -61,6 +61,7 @@ async function renderFile(req: Request, path: string) { } } } + const res = await serveFile(req, path, { fileInfo, }); @@ -112,6 +113,7 @@ async function renderPage(_req: Request, path: string, ctx: HandlerContext) { } async function GET(req: Request, ctx: HandlerContext): Promise { + const authRequired = Deno.env.get("AUTH_REQUIRED") === "true"; if (authRequired) { const login = ctx.state["login"]; @@ -192,6 +194,7 @@ export default function DirLists(props: PageProps) { <> Simple file server : {data.path} +
{data.type === "dir" diff --git a/routes/index.tsx b/routes/index.tsx index b3b5ff3..87dfa60 100644 --- a/routes/index.tsx +++ b/routes/index.tsx @@ -5,6 +5,7 @@ export default function Home() { <> Simple file server +
hello world + \ No newline at end of file diff --git a/test_data/f/SUMMARY.md b/test_data/f/SUMMARY.md index 36508d2..09b0d83 100644 --- a/test_data/f/SUMMARY.md +++ b/test_data/f/SUMMARY.md @@ -4,3 +4,15 @@ tags: ["한글", "테스트"] --- # 한글 테스트. 띄어쓰기없이도되나? + +![img](./img.jpg) + +1. asdf +2. asdf +3. sdf + + +* a +* b +* c +* d \ No newline at end of file diff --git a/test_data/f/img.jpg b/test_data/f/img.jpg new file mode 100644 index 0000000..b18729a Binary files /dev/null and b/test_data/f/img.jpg differ