chore(*): fix highlite
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
72c84425d6
commit
221cbfeafe
@ -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,28 +35,27 @@ 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();
|
||||
});
|
||||
|
||||
for (const block of codeBlocks) {
|
||||
async function loadExternalCode() {
|
||||
const codeBlocks = document.querySelectorAll("code[data-external]");
|
||||
|
||||
for (const block of codeBlocks) {
|
||||
try {
|
||||
const response = await fetch(block.dataset.external);
|
||||
const code = await response.text();
|
||||
block.textContent = code;
|
||||
|
||||
// Обновляем подсветку после загрузки кода
|
||||
if (Reveal.getPlugin('highlight')) {
|
||||
Reveal.getPlugin('highlight').hljs.highlightBlock(block);
|
||||
}
|
||||
const response = await fetch(block.dataset.external);
|
||||
const code = await response.text();
|
||||
block.textContent = code;
|
||||
|
||||
// Правильный способ обновить подсветку
|
||||
deck.getPlugin("highlight").hljs.highlightBlock(block);
|
||||
} catch (error) {
|
||||
block.textContent = '⚠️ Error loading code: ' + error.message;
|
||||
block.textContent = "⚠️ Error: " + error.message;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</Layout>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user