-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(new tool): Markdown TOC Generator
- Loading branch information
Showing
7 changed files
with
83 additions
and
6 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,12 @@ | ||
import { Table } from '@vicons/tabler'; | ||
import { defineTool } from '../tool'; | ||
|
||
export const tool = defineTool({ | ||
name: 'Markdown toc generator', | ||
path: '/markdown-toc-generator', | ||
description: 'Generate a TOC from a markdown file/content', | ||
keywords: ['markdown', 'toc', 'generator'], | ||
component: () => import('./markdown-toc-generator.vue'), | ||
icon: Table, | ||
createdAt: new Date('2024-05-11'), | ||
}); |
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,6 @@ | ||
declare module 'markdown-contents'{ | ||
declare class MarkdownContents { | ||
markdown(): string; | ||
} | ||
export default function Create(markdown: string):MarkdownContents; | ||
} |
30 changes: 30 additions & 0 deletions
30
src/tools/markdown-toc-generator/markdown-toc-generator.vue
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,30 @@ | ||
<script setup lang="ts"> | ||
import MarkdownContents from 'markdown-contents'; | ||
import { withDefaultOnError } from '@/utils/defaults'; | ||
const defaultValue = `# A title 1 | ||
## A title level 2 | ||
# Another title 1 | ||
## Another title level 2 | ||
`; | ||
function transformer(value: string) { | ||
return withDefaultOnError(() => { | ||
const generator = MarkdownContents(value); | ||
return generator.markdown(); | ||
}, ''); | ||
} | ||
</script> | ||
|
||
<template> | ||
<format-transformer | ||
input-label="Your Markdown content" | ||
:input-default="defaultValue" | ||
input-placeholder="Paste your Markdown content here..." | ||
output-label="Generated Markdown TOC" | ||
output-language="markdown" | ||
:transformer="transformer" | ||
/> | ||
</template> |