chore(*): fix highlite
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Карпич Дмитрий Александрович 2025-05-28 15:29:16 +03:00
parent 72c84425d6
commit 221cbfeafe

View File

@ -26,7 +26,7 @@ const { title, authors, description } = Astro.props;
<slot />
</div>
</div>
<script >
<script>
import Reveal from "reveal.js";
import Highlight from "reveal.js/plugin/highlight/highlight.esm.js";
import Zoom from "reveal.js/plugin/zoom/zoom.esm.js";
@ -35,10 +35,14 @@ const { title, authors, description } = Astro.props;
let deck = new Reveal({
plugins: [Highlight, Zoom, Notes],
});
deck.initialize();
document.addEventListener('DOMContentLoaded', async function() {
const codeBlocks = document.querySelectorAll('code[data-external]');
deck.initialize().then(() => {
// Загружаем внешний код после инициализации Reveal
loadExternalCode();
});
async function loadExternalCode() {
const codeBlocks = document.querySelectorAll("code[data-external]");
for (const block of codeBlocks) {
try {
@ -46,17 +50,12 @@ document.addEventListener('DOMContentLoaded', async function() {
const code = await response.text();
block.textContent = code;
// Обновляем подсветку после загрузки кода
if (Reveal.getPlugin('highlight')) {
Reveal.getPlugin('highlight').hljs.highlightBlock(block);
}
// Правильный способ обновить подсветку
deck.getPlugin("highlight").hljs.highlightBlock(block);
} catch (error) {
block.textContent = '⚠️ Error loading code: ' + error.message;
block.textContent = "⚠️ Error: " + error.message;
}
}
}
});
</script>
</Layout>