mirror of
https://github.com/litruv/Docs-Viewer.git
synced 2026-07-24 02:36:07 +10:00
Add dynamic document title setting on data load
This commit is contained in:
6
index.js
6
index.js
@@ -531,11 +531,13 @@ class Documentation {
|
||||
this.indexData = data;
|
||||
window._indexData = data;
|
||||
|
||||
window.originalDocTitle = data.title || 'Documentation';
|
||||
document.title = window.originalDocTitle;
|
||||
|
||||
this.domService.elements.fileIndex.innerHTML = '';
|
||||
this.indexData.documents.forEach(doc =>
|
||||
this.domService.createFileIndexItem(doc, this.domService.elements.fileIndex));
|
||||
|
||||
// Use defaultPage from index.json
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
let slug = '';
|
||||
if (params.has('')) {
|
||||
@@ -550,7 +552,6 @@ class Documentation {
|
||||
|
||||
await this.loadDocumentBySlug(slug);
|
||||
|
||||
// Handle hash after load using DOMService's scrollToElement
|
||||
if (window.location.hash) {
|
||||
setTimeout(() => {
|
||||
const element = document.getElementById(window.location.hash.slice(1));
|
||||
@@ -601,7 +602,6 @@ class Documentation {
|
||||
|
||||
window._currentPath = path;
|
||||
|
||||
// Handle hash scrolling after content is loaded
|
||||
if (window.location.hash) {
|
||||
const element = document.getElementById(window.location.hash.slice(1));
|
||||
if (element) {
|
||||
|
||||
Reference in New Issue
Block a user