Replies: 2 comments 4 replies
-
In vitepress, there is no wrapper class enforced by markdown. It should be added via theme - https://vitepress.dev/guide/custom-theme#building-a-layout So if someone is writing a theme and they want to add class: <!-- Layout.vue -->
<template>
<Content class="prose" />
</template> // .vitepress/theme.ts
import Layout from './Layout.vue'
export default {
Layout
} The default theme won't be compatible with your plugin for obvious style conflicts. |
Beta Was this translation helpful? Give feedback.
1 reply
-
For other people if are interested, I ended up using a custom Layout that uses Vitepress <!-- Layout.vue -->
<script setup lang="ts">
import DefaultTheme from 'vitepress/theme'
import { useMutationObserver } from '@vueuse/core'
useMutationObserver(globalThis.document.querySelector('#app') as HTMLDivElement, () => {
globalThis.document.querySelector('main.main > div')?.classList.add('vp-raw', 'prose')
}, {
subtree: true,
childList: true,
})
</script>
<template>
<DefaultTheme.Layout />
</template> I still believe that all of this JS is unnecessary. Possible solution
// .vitepress/config.ts
defineConfig({
// your config
markdown: {
wrapperClasses: 'prose'
}
}) <!-- VPDoc.vue -->
<main class="main">
<Content
class="vp-doc"
:class="[
pageName,
theme.externalLinkIcon && 'external-link-icon-enabled',
(Array.isArray(options.wrapperClasses) ? ...options.wrapperClasses : options.wrapperClasses)
]"
/>
</main> |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am building a typography plugin, very similar to https://tailwindcss.com/docs/typography-plugin
The idea is that the developer will add a class
prose
to the container and certain rules will apply.I was looking how it would be possible to use that library in Vitepress, but there is no such an option. I would like to add a new option to the
markdown
object like:This approach is very similar to
Unplugin Vue Components
I am willing to implement this feature but I would like to hear from the maintainers first, if they like it 😃
Beta Was this translation helpful? Give feedback.
All reactions