From 41d291deede53f04d31c78dfc54e8021beb42933 Mon Sep 17 00:00:00 2001 From: Mhykol Date: Mon, 13 May 2024 08:09:28 -0400 Subject: Update main.js --- assets/js/main.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/assets/js/main.js b/assets/js/main.js index 6cb2ad6..a0c714b 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -80,19 +80,20 @@ const getBlog = async (x) => { }) .then(response => response.text()) .then(text => { - main.body.innerHTML = DOMPurify.sanitize(text) - eventListener() - prism('https://fatalmatrix.xyz/js/prism.js') - window.scrollTo(0, 0) + const prism = new Promise((res, rej) => { + const script = document.createElement('script') + script.src = `${window.location.origin}/js/prism.js` + document.head.appendChild(script) + res('success') + }) + prism.then(output => { + main.body.innerHTML = DOMPurify.sanitize(text) + eventListener() + window.scrollTo(0, 0) + }) }) } -const prism = async (url) => { - const script = document.createElement('script') - script.src = url - document.head.appendChild(script) -} - const eventListener = () => { const menuList = document.getElementById('menu-list') const menuIcon = document.getElementById('menu-icon') -- cgit v1.2.3-70-g09d2