Skip to content

Commit

Permalink
Add markdown layout component
Browse files Browse the repository at this point in the history
  • Loading branch information
jlpereira committed Sep 4, 2023
1 parent d78ace1 commit 22587b7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ node_modules
.DS_Store
dist
dist-ssr
config
pages
components
panels
/config
/pages
/components
/panels
public
README.md
*.local
Expand Down
35 changes: 35 additions & 0 deletions src/components/Markdown/MarkdownLayout.global.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<template>
<component
:is="tag"
:class="layoutClasses"
>
<slot />
</component>
</template>

<script setup>
import { computed } from 'vue'
const props = defineProps({
tag: {
type: String,
default: 'div'
},
frontmatter: {
type: Object,
required: true
}
})
const LAYOUT_CLASSES = {
fullwidth: 'p-4 sm:px-0 prose dark:prose-invert max-w-none'
}
const DEFAULT_LAYOUT =
'!container mx-auto p-4 sm:px-0 prose dark:prose-invert box-border'
const layoutClasses = computed(
() => LAYOUT_CLASSES[props.frontmatter.layout] || DEFAULT_LAYOUT
)
</script>
3 changes: 1 addition & 2 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ export default () => {
}),

Markdown({
wrapperClasses:
'!container mx-auto p-4 sm:pl-0 sm:pr-0 prose dark:prose-invert box-border',
wrapperComponent: 'markdown-layout',
markdownItSetup(md) {
md.use(markdownAnchor)
md.use(variableReplacementPlugin, {
Expand Down

0 comments on commit 22587b7

Please sign in to comment.