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