Skip to content

Commit 5739153

Browse files
authored
fix: don't render controls if unnecessary (sveltejs#487)
fixes sveltejs#486
1 parent 4fe5543 commit 5739153

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/site-kit/src/lib/markdown/renderer.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,13 @@ export async function render_content_markdown(
226226
? await generate_ts_from_js(source, token.lang, options)
227227
: undefined;
228228

229-
let html = '<div class="code-block"><div class="controls">';
229+
let html = '<div class="code-block">';
230+
231+
const needs_controls = options.link || options.copy || converted;
232+
233+
if (needs_controls) {
234+
html += '<div class="controls">';
235+
}
230236

231237
if (options.file) {
232238
const ext = options.file.slice(options.file.lastIndexOf('.'));
@@ -243,7 +249,9 @@ export async function render_content_markdown(
243249
html += `<button class="copy-to-clipboard raised" title="Copy to clipboard" aria-label="Copy to clipboard"></button>`;
244250
}
245251

246-
html += '</div>';
252+
if (needs_controls) {
253+
html += '</div>';
254+
}
247255

248256
html += await syntax_highlight({ filename, language: token.lang, prelude, source, check });
249257

0 commit comments

Comments
 (0)