Skip to content

Commit dc2bb92

Browse files
committed
Cleans up some remaining issues
1 parent 1b93347 commit dc2bb92

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

src/.vitepress/components/Tabs/code-tabs.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.code-tabs-nav {
44
overflow-x: auto;
55

6-
margin: 0.85rem 0 -0.85rem;
6+
margin: 0.85rem 0 0 0;
77
padding: 0;
88
border-radius: 6px 6px 0 0;
99

@@ -101,12 +101,13 @@
101101
display: block;
102102
}
103103

104-
div[class*="language-"] {
104+
> div[class*="language-"] {
105105
border-top-left-radius: 0;
106106
border-top-right-radius: 0;
107+
margin: 0;
107108

108109
@media (max-width: 760px) {
109-
margin: 0.85rem -1.5rem;
110+
margin: 0 -1.5rem;
110111
}
111112
}
112113
}

src/.vitepress/components/code/Code.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ function current() {
123123
opacity: 0;
124124
}
125125
126+
.vp-doc [class*="language-"] > p.toggler ~ span.lang {
127+
display: none;
128+
}
129+
126130
.lang-switcher p.toggler {
127131
border: 3px solid var(--vp-button-brand-border);
128132
background-color: var(--vp-button-alt-bg);

src/.vitepress/plugins/snippets.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,23 @@ export function snippetPlugin(md: MarkdownIt, srcDir: string) {
107107
return error(`Invalid region name: ${regionName} in ${src}`);
108108
}
109109

110+
token.info = "tsx";
110111
token.content = region.ts.code;
111-
token.info = fenceInfo.highlights(region.ts.highlights);
112+
token.attrs = fenceInfo.asAttr(region.ts.highlights);
112113

113114
if (region.ts.code === region.js.code) {
115+
console.log("both", token);
116+
114117
return `<section class="both-lang">${fence(...args)}</section>`;
115118
}
116119

117120
const tsFenced = fence(...args);
118121

122+
token.info = "tsx";
119123
token.content = region.js.code;
120-
token.info = fenceInfo.highlights(region.js.highlights);
124+
token.attrs = fenceInfo.asAttr(region.js.highlights);
125+
console.log("js", token);
126+
121127
const jsFenced = fence(...args);
122128

123129
return `<Code><template #ts>${tsFenced}</template><template #js>${jsFenced}</template></Code>`;
@@ -131,11 +137,9 @@ export function snippetPlugin(md: MarkdownIt, srcDir: string) {
131137
}
132138

133139
token.content = snippet.ts.code;
134-
135140
const tsFenced = fence(...args);
136141

137142
token.content = snippet.js.code;
138-
token.info = `ts${token.info.slice(3)}`;
139143
const jsFenced = fence(...args);
140144

141145
return `<Code><template #ts>${tsFenced}</template><template #js>${jsFenced}</template></Code>`;
@@ -174,15 +178,19 @@ class FenceInfo {
174178
this.#original = original;
175179
}
176180

177-
highlights(highlights: Highlight[]) {
178-
if (highlights.length === 0) {
179-
return `ts`;
180-
} else {
181-
return `ts{${highlights
182-
.map((h) => h.lines)
183-
.join(",")}}${this.#original.slice(3)}`;
184-
}
181+
asAttr(highlights: Highlight[]): [string, string][] {
182+
return [[highlights.map((h) => h.lines).join(","), ""]];
185183
}
184+
185+
// highlights(highlights: Highlight[]) {
186+
// if (highlights.length === 0) {
187+
// return `ts`;
188+
// } else {
189+
// return `ts{${highlights
190+
// .map((h) => h.lines)
191+
// .join(",")}}${this.#original.slice(3)}`;
192+
// }
193+
// }
186194
}
187195

188196
function error(message: string) {

0 commit comments

Comments
 (0)