1
0
Fork 0

Import existing project

This commit is contained in:
Caileb 2025-05-26 12:42:36 -05:00
parent 7887817595
commit 80b0cc4939
125 changed files with 16980 additions and 0 deletions

48
develop/js/docs.js Normal file
View file

@ -0,0 +1,48 @@
import { highlightElement } from 'https://unpkg.com/@speed-highlight/core@1.2.7/dist/index.js';
document.addEventListener('DOMContentLoaded', () => {
// Initialize Syntax Highlighting
initSyntaxHighlighting();
});
/**
* Initialize syntax highlighting using Speed Highlight JS
* This is a reusable function that applies syntax highlighting to code blocks
*/
async function initSyntaxHighlighting() {
try {
// Get all code blocks
const codeBlocks = document.querySelectorAll('.code-example pre code');
codeBlocks.forEach(block => {
// Determine language from code-label
let lang = 'html'; // Default to HTML
const example = block.closest('.code-example');
if (example) {
const label = example.querySelector('.code-label');
if (label) {
const labelText = label.textContent.trim().toLowerCase();
if (labelText === 'css') lang = 'css';
if (labelText === 'js' || labelText === 'javascript') lang = 'js';
if (labelText === 'go' || labelText === 'golang') lang = 'go';
if (labelText === 'json') lang = 'json';
if (labelText === 'http') lang = 'http';
}
}
// Create a new element to hold the highlighted code
const highlighted = document.createElement('div');
highlighted.className = `shj-lang-${lang}`;
highlighted.textContent = block.textContent;
// Replace the pre with our new element
const pre = block.parentElement;
pre.parentNode.replaceChild(highlighted, pre);
// Apply highlighting directly
highlightElement(highlighted, lang);
});
} catch (error) {
console.warn('Syntax highlighting failed to initialize:', error);
}
}