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