mirror of
https://github.com/PR0M3TH3AN/Archivox.git
synced 2025-09-08 06:58:43 +00:00
Fix sidebar toggle and navigation titles
This commit is contained in:
@@ -59,9 +59,10 @@ body {
|
|||||||
background: var(--sidebar-bg);
|
background: var(--sidebar-bg);
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
}
|
}
|
||||||
.sidebar ul { list-style: none; padding: 0; }
|
.sidebar ul { list-style: none; padding: 0; margin: 0; }
|
||||||
.sidebar ul ul { padding-left: 1rem; }
|
.sidebar li { margin: 0.25rem 0; }
|
||||||
.sidebar a { text-decoration: none; color: var(--text-color); }
|
.sidebar a { text-decoration: none; color: var(--text-color); display: block; padding: 0.25rem 0; }
|
||||||
|
.sidebar ul ul { padding-left: 1rem; margin-left: 0.5rem; border-left: 2px solid #ccc; }
|
||||||
main {
|
main {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
@@ -74,7 +75,7 @@ main {
|
|||||||
top: 0;
|
top: 0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
transition: left 0.3s ease;
|
transition: none;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
}
|
}
|
||||||
body.sidebar-open .sidebar { left: 0; }
|
body.sidebar-open .sidebar { left: 0; }
|
||||||
|
@@ -26,10 +26,29 @@ function buildNav(pages) {
|
|||||||
const tree = {};
|
const tree = {};
|
||||||
for (const page of pages) {
|
for (const page of pages) {
|
||||||
const rel = page.file.replace(/\\/g, '/');
|
const rel = page.file.replace(/\\/g, '/');
|
||||||
|
if (rel === 'index.md') {
|
||||||
|
if (!tree.children) tree.children = [];
|
||||||
|
tree.children.push({
|
||||||
|
name: 'index.md',
|
||||||
|
children: [],
|
||||||
|
page: page.data,
|
||||||
|
path: `/${rel.replace(/\.md$/, '.html')}`,
|
||||||
|
order: page.data.order || 0
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const parts = rel.split('/');
|
const parts = rel.split('/');
|
||||||
let node = tree;
|
let node = tree;
|
||||||
for (let i = 0; i < parts.length; i++) {
|
for (let i = 0; i < parts.length; i++) {
|
||||||
const part = parts[i];
|
const part = parts[i];
|
||||||
|
const isLast = i === parts.length - 1;
|
||||||
|
const isIndex = isLast && part === 'index.md';
|
||||||
|
if (isIndex) {
|
||||||
|
node.page = page.data;
|
||||||
|
node.path = `/${rel.replace(/\.md$/, '.html')}`;
|
||||||
|
node.order = page.data.order || 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (!node.children) node.children = [];
|
if (!node.children) node.children = [];
|
||||||
let child = node.children.find(c => c.name === part);
|
let child = node.children.find(c => c.name === part);
|
||||||
if (!child) {
|
if (!child) {
|
||||||
@@ -37,12 +56,12 @@ function buildNav(pages) {
|
|||||||
node.children.push(child);
|
node.children.push(child);
|
||||||
}
|
}
|
||||||
node = child;
|
node = child;
|
||||||
if (i === parts.length - 1) {
|
if (isLast) {
|
||||||
node.page = page.data;
|
node.page = page.data;
|
||||||
node.path = `/${rel.replace(/\.md$/, '.html')}`;
|
node.path = `/${rel.replace(/\.md$/, '.html')}`;
|
||||||
|
node.order = page.data.order || 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
node.order = page.data.order || 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function sort(node) {
|
function sort(node) {
|
||||||
@@ -92,8 +111,9 @@ async function generate({ contentDir = 'content', outputDir = '_site', configPat
|
|||||||
const mdObj = await runHook('onParseMarkdown', { file: rel, content: raw });
|
const mdObj = await runHook('onParseMarkdown', { file: rel, content: raw });
|
||||||
if (mdObj && mdObj.content) raw = mdObj.content;
|
if (mdObj && mdObj.content) raw = mdObj.content;
|
||||||
const parsed = matter(raw);
|
const parsed = matter(raw);
|
||||||
const title = parsed.data.title || path.basename(rel, '.md');
|
|
||||||
const tokens = lexer(parsed.content || '');
|
const tokens = lexer(parsed.content || '');
|
||||||
|
const firstHeading = tokens.find(t => t.type === 'heading');
|
||||||
|
const title = parsed.data.title || (firstHeading ? firstHeading.text : path.basename(rel, '.md'));
|
||||||
const headings = tokens.filter(t => t.type === 'heading').map(t => t.text).join(' ');
|
const headings = tokens.filter(t => t.type === 'heading').map(t => t.text).join(' ');
|
||||||
pages.push({ file: rel, data: { ...parsed.data, title } });
|
pages.push({ file: rel, data: { ...parsed.data, title } });
|
||||||
searchDocs.push({ id: rel.replace(/\.md$/, '.html'), url: '/' + rel.replace(/\.md$/, '.html'), title, headings });
|
searchDocs.push({ id: rel.replace(/\.md$/, '.html'), url: '/' + rel.replace(/\.md$/, '.html'), title, headings });
|
||||||
|
Reference in New Issue
Block a user