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 />
|
<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,28 +35,27 @@ const { title, authors, description } = Astro.props;
|
|||||||
let deck = new Reveal({
|
let deck = new Reveal({
|
||||||
plugins: [Highlight, Zoom, Notes],
|
plugins: [Highlight, Zoom, Notes],
|
||||||
});
|
});
|
||||||
deck.initialize();
|
|
||||||
|
deck.initialize().then(() => {
|
||||||
document.addEventListener('DOMContentLoaded', async function() {
|
// Загружаем внешний код после инициализации Reveal
|
||||||
const codeBlocks = document.querySelectorAll('code[data-external]');
|
loadExternalCode();
|
||||||
|
});
|
||||||
for (const block of codeBlocks) {
|
|
||||||
|
async function loadExternalCode() {
|
||||||
|
const codeBlocks = document.querySelectorAll("code[data-external]");
|
||||||
|
|
||||||
|
for (const block of codeBlocks) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(block.dataset.external);
|
const response = await fetch(block.dataset.external);
|
||||||
const code = await response.text();
|
const code = await response.text();
|
||||||
block.textContent = code;
|
block.textContent = code;
|
||||||
|
|
||||||
// Обновляем подсветку после загрузки кода
|
|
||||||
if (Reveal.getPlugin('highlight')) {
|
|
||||||
Reveal.getPlugin('highlight').hljs.highlightBlock(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Правильный способ обновить подсветку
|
||||||
|
deck.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>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user