Skip to content

Commit

Permalink
Add styling
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanlee85 committed Jul 8, 2024
1 parent aabc9ba commit 288fab9
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions examples/polyfill_io-replace/public/assets/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
document.addEventListener('DOMContentLoaded', (event) => {
const codeBlock = document.createElement('pre');
const codeContent = document.createElement('code');
codeContent.className = 'language-html';
codeContent.textContent = document.documentElement.outerHTML;
codeBlock.appendChild(codeContent);
codeBlock.className =
'code-block bg-gray-900 text-gray-100 p-4 rounded mt-4 overflow-x-auto text-sm';

const explanationParagraph = document.createElement('p');
explanationParagraph.className = 'mt-4 text-base text-gray-600';
explanationParagraph.textContent =
'The code block below shows the current HTML document source after the edge function has processed it:';

const lastParagraph = document.querySelector('body p:last-of-type');
if (lastParagraph) {
lastParagraph.insertAdjacentElement('afterend', explanationParagraph);
explanationParagraph.insertAdjacentElement('afterend', codeBlock);
} else {
document.body.appendChild(explanationParagraph);
document.body.appendChild(codeBlock);
}

Prism.highlightElement(codeContent);
});

0 comments on commit 288fab9

Please sign in to comment.