From 3531a392301c99bc910ab5df04330aa39c27a4fb Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Mon, 21 Oct 2024 10:42:20 +0200 Subject: [PATCH] fix: don't render controls if unnecessary fixes #486 --- packages/site-kit/src/lib/markdown/renderer.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/site-kit/src/lib/markdown/renderer.ts b/packages/site-kit/src/lib/markdown/renderer.ts index 0b4b9f32c..ace7b0398 100644 --- a/packages/site-kit/src/lib/markdown/renderer.ts +++ b/packages/site-kit/src/lib/markdown/renderer.ts @@ -226,7 +226,13 @@ export async function render_content_markdown( ? await generate_ts_from_js(source, token.lang, options) : undefined; - let html = '
'; + let html = '
'; + + const needs_controls = options.link || options.copy || converted; + + if (needs_controls) { + html += '
'; + } if (options.file) { const ext = options.file.slice(options.file.lastIndexOf('.')); @@ -243,7 +249,9 @@ export async function render_content_markdown( html += ``; } - html += '
'; + if (needs_controls) { + html += '
'; + } html += await syntax_highlight({ filename, language: token.lang, prelude, source, check });