Skip to content

Commit 56d36cc

Browse files
committed
resolve comments
1 parent e128684 commit 56d36cc

File tree

3 files changed

+7
-18
lines changed

3 files changed

+7
-18
lines changed

src/.vitepress/config.mts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export default defineConfig({
2121
},
2222
markdown: {
2323
config(md) {
24-
// Fix for image width and height handling for proper scrolling
2524
const maxHeight = 500 /* px */
2625

2726
const img = md.renderer.rules.image!
@@ -30,27 +29,22 @@ export default defineConfig({
3029

3130
const widthAttr = token.attrGet('width')
3231
const heightAttr = token.attrGet('height')
33-
const existingStyle = token.attrGet('style') || ''
34-
35-
const style: string[] = []
3632

3733
let w = widthAttr ? Number.parseInt(widthAttr, 10) : null
3834
let h = heightAttr ? Number.parseInt(heightAttr, 10) : null
3935

36+
let style = token.attrGet('style') || ''
37+
if (style && !style.trim().endsWith(';')) style += ';'
38+
4039
if (w) {
4140
if (h && h > maxHeight) {
42-
const scale = maxHeight / h
43-
w = Math.round(w * scale)
41+
w = Math.round(w * maxHeight / h)
4442
h = maxHeight
4543
}
46-
style.push(`width: ${w}px;`)
47-
}
48-
49-
if (style.length > 0) {
50-
const sep = existingStyle && !existingStyle.trim().endsWith(';') ? ';' : ''
51-
token.attrSet('style', existingStyle + sep + style.join(' '))
44+
style += `width: ${w}px;`
5245
}
5346

47+
token.attrSet('style', style)
5448
return img(tokens, idx, options, env, self)
5549
}
5650

src/.vitepress/theme/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// https://vitepress.dev/guide/custom-theme
2-
import { h, nextTick, watch } from "vue";
2+
import { h } from "vue";
33
import type { Theme } from "vitepress";
44
import DefaultTheme, { VPBadge } from "vitepress/theme";
55
import "./style.css";

src/.vitepress/theme/style.css

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,3 @@ img {
156156
align-items: center;
157157
gap: 0.25em;
158158
}
159-
160-
h1, h2, h3, h4, h5{
161-
/** For proper anchor offset when using scroll to hash links */
162-
scroll-margin-top: 60px;
163-
}

0 commit comments

Comments
 (0)