mirror of
https://github.com/litruv/Docs-Viewer.git
synced 2026-07-24 02:36:07 +10:00
custom css
This commit is contained in:
19
index.js
19
index.js
@@ -756,6 +756,20 @@ class Documentation {
|
||||
this.setupKeyboardShortcuts();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a custom CSS file if specified in the index.json
|
||||
* @param {string} customCSSPath - Path to the custom CSS file relative to document root
|
||||
*/
|
||||
loadCustomCSS(customCSSPath) {
|
||||
if (!customCSSPath) return;
|
||||
|
||||
const link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.type = 'text/css';
|
||||
link.href = customCSSPath; // Path is relative to document root
|
||||
document.head.appendChild(link);
|
||||
}
|
||||
|
||||
setupEventListeners() {
|
||||
this.eventBus.on('navigation:requested', async ({ slug, hash }) => {
|
||||
slug = slug.replace(/^[?=]/, '');
|
||||
@@ -864,6 +878,11 @@ class Documentation {
|
||||
this.indexData = data;
|
||||
window._indexData = data;
|
||||
|
||||
// Load custom CSS if provided in index.json
|
||||
if (data.customCSS) {
|
||||
this.loadCustomCSS(data.customCSS);
|
||||
}
|
||||
|
||||
this.searchService.buildSearchIndex(this.indexData.documents);
|
||||
this.domService.setupSearch(this.searchService);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user