Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ordered and unordered lists not rendering correctly #30

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/[email protected].1/",
"$fresh/": "https://deno.land/x/[email protected].3/",
"tailwindcss": "npm:[email protected]",
"preact": "https://esm.sh/[email protected]",
"preact/": "https://esm.sh/[email protected]/",
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/[email protected]/path/mod.ts";
export * as JSONC from "https://deno.land/[email protected]/jsonc/mod.ts";
export { extract } from "https://deno.land/[email protected]/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/[email protected]/dotenv/mod.ts";
export { existsSync } from "https://deno.land/[email protected]/fs/mod.ts";
export { Client } from "https://deno.land/x/[email protected]/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/[email protected].1/";
denoJson.imports["$fresh/"] = "https://deno.land/x/[email protected].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/[email protected].1/",
"$fresh/": "https://deno.land/x/[email protected].3/",
"preact": "https://esm.sh/[email protected]",
"preact/": "https://esm.sh/[email protected]/",
"@preact/signals": "https://esm.sh/*@preact/[email protected]",
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/[email protected].1/",
"$fresh/": "https://deno.land/x/[email protected].3/",
"preact": "https://esm.sh/[email protected]",
"preact/": "https://esm.sh/[email protected]/",
"@preact/signals": "https://esm.sh/*@preact/[email protected]",
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/[email protected].1/",
"$fresh/": "https://deno.land/x/[email protected].3/",
"preact": "https://esm.sh/[email protected]",
"preact/": "https://esm.sh/[email protected]/",
"@preact/signals": "https://esm.sh/*@preact/[email protected]",
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/[email protected].1/",
"$fresh/": "https://deno.land/x/[email protected].3/",
"preact": "https://esm.sh/[email protected]",
"preact/": "https://esm.sh/[email protected]/",
"@preact/signals": "https://esm.sh/*@preact/[email protected]",
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/[email protected].1/",
"$fresh/": "https://deno.land/x/[email protected].3/",
"preact": "https://esm.sh/[email protected]",
"preact/": "https://esm.sh/[email protected]/",
"@preact/signals": "https://esm.sh/*@preact/[email protected]",
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/[email protected].1/",
"$fresh/": "https://deno.land/x/[email protected].3/",
"preact": "https://esm.sh/[email protected]",
"preact/": "https://esm.sh/[email protected]/",
"@preact/signals": "https://esm.sh/*@preact/[email protected]",
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/[email protected].1/",
"$fresh/": "https://deno.land/x/[email protected].3/",
"preact": "https://esm.sh/[email protected]",
"preact/": "https://esm.sh/[email protected]/",
"@preact/signals": "https://esm.sh/*@preact/[email protected]",
Expand Down