Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(markdoc): We have GFM support at home
- Loading branch information
1 parent
b899798
commit ce5608a
Showing
4 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters