remove css plugin

This commit is contained in:
monoid 2023-01-07 02:37:35 +09:00
parent b552553edb
commit 6ce9767e3b
11 changed files with 40 additions and 24 deletions

View File

@ -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 ? <div>
<h2>Meta</h2>
<pre>{meta}</pre>
<hr class="mt-2 mb-2"></hr>
</div> : <div></div>}
<div
class="markdown-body"
dangerouslySetInnerHTML={{ __html: marked.parse(c) }}
>
>
</div>
</>
);
}

View File

@ -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) {

20
main.ts
View File

@ -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,
});

View File

@ -7,6 +7,7 @@ export const handler = async (
req: Request,
ctx: MiddlewareHandlerContext<Record<string, unknown>>,
) => {
const secret_key = await prepareSecretKey();
const cookies = getCookies(req.headers);
const jwt = cookies["auth"];

View File

@ -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<Response> {
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<DirOrFileProps>) {
<>
<Head>
<title>Simple file server : {data.path}</title>
<link rel="stylesheet" href={asset("/github-markdown.css")} />
</Head>
<div class="p-4 mx-auto max-w-screen-md">
{data.type === "dir"

View File

@ -5,6 +5,7 @@ export default function Home() {
<>
<Head>
<title>Simple file server</title>
</Head>
<div class="p-4 mx-auto max-w-screen-md">
<img

View File

@ -104,6 +104,7 @@
font-size: 16px;
line-height: 1.5;
word-wrap: break-word;
}
.markdown-body .octicon {
@ -1034,3 +1035,10 @@
.markdown-body ::-webkit-calendar-picker-indicator {
filter: invert(50%);
}
.markdown-body ol{
list-style-type: decimal;
}
.markdown-body ul{
list-style-type: disc;
}

BIN
test_data/a/img.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View File

@ -12,5 +12,6 @@
</head>
<body>
hello world
<img src="img.jpg"/>
</body>
</html>

View File

@ -4,3 +4,15 @@ tags: ["한글", "테스트"]
---
# 한글 테스트. 띄어쓰기없이도되나?
![img](./img.jpg)
1. asdf
2. asdf
3. sdf
* a
* b
* c
* d

BIN
test_data/f/img.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB