Skip to content

Commit

Permalink
feat(markdoc): We have GFM support at home
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh committed Mar 6, 2024
1 parent b899798 commit ce5608a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
4 changes: 4 additions & 0 deletions markdoc.config.mjs
Expand Up @@ -14,6 +14,10 @@ export default defineMarkdocConfig({
attributes: nodes.link.attributes,
render: component("./src/components/ExternalLink.astro"),
},
list: {
attributes: nodes.list.attributes,
render: component("./src/components/content/List.astro"),
},
},
tags: {
blockquote: {
Expand Down
23 changes: 23 additions & 0 deletions src/components/content/List.astro
@@ -0,0 +1,23 @@
---
let content = await Astro.slots.render("default");
const isTaskList = content.match(/\[ ]|\[x\]/g);
const classList = isTaskList ? "task-list" : "";
// We have GFM support at home
if (isTaskList && isTaskList.length > 0) {
content = content.replaceAll(
/<li>\[ ?\]/gm,
"<li class='task-list-item'><input type='checkbox' inert />",
);
content = content.replaceAll(
"<li>[x]",
"<li class='task-list-item'><input type='checkbox' checked inert />",
);
content = content.replaceAll("<li>", "<li class='list-inside'>");
}
---

<ul class={classList}>
<Fragment set:html={content} />
</ul>
4 changes: 2 additions & 2 deletions src/content/wiki/computers/zed-wishlist/zed-wishlist.mdoc
Expand Up @@ -18,8 +18,8 @@ I've recently been using the [Zed code editor](https://zed.dev/) and really enjo
- [ ] Rainbow brackets
- [ ] Indentation guides
- [ ] Indentation guides in the explorer panel, too (especially, actually)
- [ ] Client-side filtering for LSP completions
- [ ] Image viewer
- [ ] Client-side filtering for LSP completions
- [ ] Image viewer

## Annoyances

Expand Down
15 changes: 15 additions & 0 deletions tailwind.config.ts
Expand Up @@ -412,6 +412,21 @@ export default {
display: "block",
},

"article>ul, article>ol": {
margin: "0",
padding: "0",
paddingLeft: "1.5em",
},

"li>ul, li>ol": {
padding: "0",
paddingLeft: "1.5em",
},

".task-list-item": {
listStyleType: "none",
},

".header-anchor": {
color: "inherit",
paddingLeft: "1.5ch",
Expand Down

0 comments on commit ce5608a

Please sign in to comment.