Skip to content

Commit

Permalink
fix: don't render controls if unnecessary (#487)
Browse files Browse the repository at this point in the history
fixes #486
  • Loading branch information
dummdidumm authored Oct 21, 2024
1 parent 4fe5543 commit 5739153
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/site-kit/src/lib/markdown/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,13 @@ export async function render_content_markdown(
? await generate_ts_from_js(source, token.lang, options)
: undefined;

let html = '<div class="code-block"><div class="controls">';
let html = '<div class="code-block">';

const needs_controls = options.link || options.copy || converted;

if (needs_controls) {
html += '<div class="controls">';
}

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

html += '</div>';
if (needs_controls) {
html += '</div>';
}

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

Expand Down

0 comments on commit 5739153

Please sign in to comment.