Skip to content

Commit d319dbb

Browse files
committed
feat: add basic styles
1 parent 5c91fc8 commit d319dbb

File tree

4 files changed

+127
-11
lines changed

4 files changed

+127
-11
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"bumpp",
55
"changelogithub",
66
"commitlint",
7+
"mdast",
78
"preid",
89
"unplugin"
910
],

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
},
4545
"dependencies": {
4646
"mdast-util-from-markdown": "^2.0.2",
47-
"mdast-util-to-vnode": "^0.3.0"
47+
"mdast-util-gfm": "^3.1.0",
48+
"mdast-util-to-vnode": "^0.3.2",
49+
"micromark-extension-gfm": "^3.0.0"
4850
},
4951
"devDependencies": {
5052
"@antfu/eslint-config": "^3.14.0",

pnpm-lock.yaml

Lines changed: 15 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/VueMarkdown.vue

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<script setup lang="ts">
22
import { fromMarkdown } from 'mdast-util-from-markdown'
3+
import { gfmFromMarkdown } from 'mdast-util-gfm'
34
import { toVNode } from 'mdast-util-to-vnode'
5+
import { gfm } from 'micromark-extension-gfm'
46
import { computed } from 'vue'
57
68
defineOptions({
@@ -13,7 +15,15 @@ const props = withDefaults(defineProps<{
1315
md: '',
1416
})
1517
16-
const vNode = computed(() => toVNode(fromMarkdown(props.md)))
18+
// const vNode = computed(() => toVNode(fromMarkdown(props.md)))
19+
const vNode = computed(() => {
20+
const ast = fromMarkdown(props.md, {
21+
extensions: [gfm()],
22+
mdastExtensions: [gfmFromMarkdown()],
23+
})
24+
25+
return toVNode(ast)
26+
})
1727
</script>
1828

1929
<template>
@@ -23,6 +33,103 @@ const vNode = computed(() => toVNode(fromMarkdown(props.md)))
2333
</template>
2434

2535
<style lang="scss">
36+
:root {
37+
--vue-markdown-font-size: 16px;
38+
--vue-markdown-heading-font-weight: 600;
39+
}
40+
2641
.vue-markdown {
42+
font-size: var(--vue-markdown-font-size, 16px);
43+
line-height: 1.5;
44+
45+
p {
46+
margin: 0;
47+
}
48+
49+
h1,
50+
h2,
51+
h3,
52+
h4,
53+
h5,
54+
h6 {
55+
font-weight: var(--vue-markdown-heading-font-weight, 600);
56+
margin: 0;
57+
margin-top: 12px;
58+
}
59+
h1 {
60+
margin-top: 32px;
61+
font-size: calc(var(--vue-markdown-font-size) * 1.75);
62+
line-height: 1.75;
63+
}
64+
h2 {
65+
font-size: calc(var(--vue-markdown-font-size) * 1.5);
66+
}
67+
h3 {
68+
font-size: calc(var(--vue-markdown-font-size) * 1.25);
69+
}
70+
h4 {
71+
font-size: calc(var(--vue-markdown-font-size) * 1.125);
72+
}
73+
h5 {
74+
font-size: calc(var(--vue-markdown-font-size) * 1);
75+
}
76+
h6 {
77+
font-size: calc(var(--vue-markdown-font-size) * 0.875);
78+
}
79+
80+
blockquote {
81+
margin: 0;
82+
padding-left: 12px;
83+
position: relative;
84+
85+
&::before {
86+
content: '';
87+
position: absolute;
88+
left: 0;
89+
height: 100%;
90+
width: 4px;
91+
background: oklch(0.13 0.028 261.692);
92+
border-radius: 9999px;
93+
}
94+
}
95+
96+
a {
97+
color: oklch(0.707 0.165 254.624);
98+
transition: color ease-out 0.3s;
99+
100+
&:hover {
101+
color: oklch(0.623 0.214 259.815);
102+
}
103+
}
104+
105+
hr {
106+
border-width: 0;
107+
border-top-width: 1px;
108+
border-color: oklch(0.872 0.01 258.338);
109+
}
110+
111+
pre {
112+
padding: 16px;
113+
background: oklch(0.928 0.006 264.531);
114+
border-radius: 8px;
115+
}
116+
code:not(pre > code) {
117+
background: oklch(0.928 0.006 264.531);
118+
padding: 2px 4px;
119+
border-radius: 4px;
120+
white-space: nowrap;
121+
margin: 0 4px;
122+
}
123+
124+
img {
125+
max-width: 40%;
126+
}
127+
128+
strong {
129+
font-weight: 600;
130+
}
131+
s {
132+
text-decoration: line-through;
133+
}
27134
}
28135
</style>

0 commit comments

Comments
 (0)