Skip to content

Commit

Permalink
fix: ordered and unordered lists not rendering correctly (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
deer authored Jan 17, 2024
1 parent 13ae8ca commit 754ccdc
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 11 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"ok": "deno fmt --check && deno lint && deno task check:types && deno task test"
},
"imports": {
"$fresh/": "https://deno.land/x/fresh@1.6.1/",
"$fresh/": "https://deno.land/x/fresh@1.6.3/",
"tailwindcss": "npm:tailwindcss@3.3.5",
"preact": "https://esm.sh/preact@10.19.2",
"preact/": "https://esm.sh/preact@10.19.2/",
Expand Down
2 changes: 1 addition & 1 deletion deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export {
} from "https://deno.land/std@0.208.0/path/mod.ts";
export * as JSONC from "https://deno.land/std@0.208.0/jsonc/mod.ts";
export { extract } from "https://deno.land/std@0.208.0/front_matter/yaml.ts";
export { CSS, render } from "https://deno.land/x/gfm@0.2.5/mod.ts";
export { CSS, render, Renderer } from "https://deno.land/x/gfm@0.5.0/mod.ts";
export { load } from "https://deno.land/std@0.208.0/dotenv/mod.ts";
export { existsSync } from "https://deno.land/std@0.208.0/fs/mod.ts";
export { Client } from "https://deno.land/x/notion_sdk@v2.2.3/src/mod.ts";
Expand Down
2 changes: 1 addition & 1 deletion src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async function modifyDenoJson() {
return;
}

denoJson.imports["$fresh/"] = "https://deno.land/x/fresh@1.6.1/";
denoJson.imports["$fresh/"] = "https://deno.land/x/fresh@1.6.3/";

const denoJsonContent = JSON.stringify(denoJson, null, 2) + "\n";
await Deno.writeTextFile(DENO_JSON_PATH, denoJsonContent);
Expand Down
16 changes: 15 additions & 1 deletion src/routes/blog/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Head,
PageProps,
render,
Renderer,
} from "../../../deps.ts";
import { Localization } from "../../plugin/blog.ts";
import { Post } from "../../utils/posts.ts";
Expand Down Expand Up @@ -40,7 +41,20 @@ export const handler: Handlers<Post, BlogState> = {
export function createPostPage(title: string, localization: Localization) {
return function PostPage(props: PageProps<Post>) {
const post = props.data;
const html = render(post.content!);
class CustomRenderer extends Renderer {
list(body: string, ordered: boolean): string {
const type = ordered ? "list-decimal" : "list-disc";
const tag = ordered ? "ol" : "ul";
return `<${tag} class="${type}">${body}</${tag}>`;
}
}
const html = render(post.content!, {
renderer: new CustomRenderer({}),
allowedClasses: {
ul: ["list-disc"],
ol: ["list-decimal"],
},
});
return (
<>
<Head>
Expand Down
2 changes: 2 additions & 0 deletions src/safelist.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const safelist = [
"list-disc",
"list-decimal",
"max-w-screen-md",
"px-4",
"pt-16",
Expand Down
2 changes: 1 addition & 1 deletion tests/empty_posts_dir_fixture/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"preview": "deno run -A main.ts"
},
"imports": {
"$fresh/": "https://deno.land/x/fresh@1.6.1/",
"$fresh/": "https://deno.land/x/fresh@1.6.3/",
"preact": "https://esm.sh/preact@10.19.2",
"preact/": "https://esm.sh/preact@10.19.2/",
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.1",
Expand Down
2 changes: 1 addition & 1 deletion tests/fixture/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"preview": "deno run -A main.ts"
},
"imports": {
"$fresh/": "https://deno.land/x/fresh@1.6.1/",
"$fresh/": "https://deno.land/x/fresh@1.6.3/",
"preact": "https://esm.sh/preact@10.19.2",
"preact/": "https://esm.sh/preact@10.19.2/",
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.1",
Expand Down
8 changes: 8 additions & 0 deletions tests/fixture/posts/markdown-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@ hello
## Not quite as big

~~hey again~~

- a
- b
- c

1. a
2. b
3. c
2 changes: 1 addition & 1 deletion tests/localization_fixture/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"preview": "deno run -A main.ts"
},
"imports": {
"$fresh/": "https://deno.land/x/fresh@1.6.1/",
"$fresh/": "https://deno.land/x/fresh@1.6.3/",
"preact": "https://esm.sh/preact@10.19.2",
"preact/": "https://esm.sh/preact@10.19.2/",
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.1",
Expand Down
2 changes: 1 addition & 1 deletion tests/no_posts_dir_fixture/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"preview": "deno run -A main.ts"
},
"imports": {
"$fresh/": "https://deno.land/x/fresh@1.6.1/",
"$fresh/": "https://deno.land/x/fresh@1.6.3/",
"preact": "https://esm.sh/preact@10.19.2",
"preact/": "https://esm.sh/preact@10.19.2/",
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.1",
Expand Down
2 changes: 1 addition & 1 deletion tests/notion_no_posts_dir_fixture/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"preview": "deno run -A main.ts"
},
"imports": {
"$fresh/": "https://deno.land/x/fresh@1.6.1/",
"$fresh/": "https://deno.land/x/fresh@1.6.3/",
"preact": "https://esm.sh/preact@10.19.2",
"preact/": "https://esm.sh/preact@10.19.2/",
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.1",
Expand Down
2 changes: 1 addition & 1 deletion tests/responsive_navbar_fixture/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"preview": "deno run -A main.ts"
},
"imports": {
"$fresh/": "https://deno.land/x/fresh@1.6.1/",
"$fresh/": "https://deno.land/x/fresh@1.6.3/",
"preact": "https://esm.sh/preact@10.19.2",
"preact/": "https://esm.sh/preact@10.19.2/",
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.1",
Expand Down
2 changes: 1 addition & 1 deletion tests/separate_index_fixture/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"preview": "deno run -A main.ts"
},
"imports": {
"$fresh/": "https://deno.land/x/fresh@1.6.1/",
"$fresh/": "https://deno.land/x/fresh@1.6.3/",
"preact": "https://esm.sh/preact@10.19.2",
"preact/": "https://esm.sh/preact@10.19.2/",
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.1",
Expand Down

0 comments on commit 754ccdc

Please sign in to comment.