Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
197 additions
and
22 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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,50 @@ | ||
import { defineNuxtModule } from '@nuxt/kit' | ||
import Markdown from 'vite-plugin-vue-markdown' | ||
import LinkAttributes from 'markdown-it-link-attributes' | ||
import { getHighlighter } from 'shiki' | ||
|
||
export default defineNuxtModule({ | ||
async setup(_, nuxt) { | ||
nuxt.options.imports.transform ||= {} | ||
nuxt.options.imports.transform.include = [/\.vue$/, /\.md$/] | ||
|
||
// @ts-expect-error any | ||
nuxt.options.components.transform ||= {} | ||
// @ts-expect-error any | ||
nuxt.options.components.transform.include = [/\.vue$/, /\.md$/] | ||
|
||
nuxt.options.vite.vue ||= {} | ||
nuxt.options.vite.vue.include = [/\.vue$/, /\.md$/] | ||
|
||
nuxt.options.extensions.push('.md') | ||
|
||
const highlighter = await getHighlighter({ | ||
themes: [ | ||
'vitesse-dark', | ||
'vitesse-light', | ||
], | ||
}) | ||
nuxt.hook('vite:extendConfig', async (config) => { | ||
config.plugins!.push( | ||
Markdown({ | ||
markdownItSetup(md) { | ||
md.use(LinkAttributes, { | ||
matcher: (link: string) => /^https?:\/\//.test(link), | ||
attrs: { | ||
target: '_blank', | ||
rel: 'noopener', | ||
}, | ||
}) | ||
md.options.highlight = (code, lang) => { | ||
const dark = highlighter.codeToHtml(code, { lang, theme: 'vitesse-dark' }) | ||
.replace('<pre class="shiki"', '<pre class="shiki shiki-dark"') | ||
const light = highlighter.codeToHtml(code, { lang: lang || 'text', theme: 'vitesse-light' }) | ||
.replace('<pre class="shiki"', '<pre class="shiki shiki-light"') | ||
return `<div class="shiki-container">${dark}${light}</div>` | ||
} | ||
}, | ||
}), | ||
) | ||
}) | ||
}, | ||
}) |
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
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
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
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
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
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
Oops, something went wrong.