Skip to content

Commit

Permalink
website: add docs.html
Browse files Browse the repository at this point in the history
  • Loading branch information
z3nnix committed Jan 16, 2025
1 parent e6532f5 commit d4dc97b
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 3 deletions.
85 changes: 85 additions & 0 deletions website/docs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>Documentation</title>
<style>
#docs-tree {
width: 30%;
float: left;
}
#docs-content {
width: 70%;
float: left;
}
</style>
</head>
<body>
<header>
<div class="container">
<h1>NovariaOS - Docs</h1>
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="https://github.com/z3nnix/novariaos">Github</a></li>
<li><a href="https://novariaos.t.me">Telegram</a></li>
<li><a href="docs.html">Docs</a></li>
<li><a href="index.html">About</a></li>
<li><a href="index.html">Download</a></li>
<li><a href="index.html">Contact</a></li>
</ul>
</nav>
</div>
</header>

<div id="docs-tree" class="list"></div>
<div id="docs-content"></div>

<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script>
const repoOwner = 'z3nnix';
const repoName = 'novariaos';

async function fetchRepoContents(path = '') {
const response = await fetch(`https://api.github.com/repos/${repoOwner}/${repoName}/contents/docs/${path}`);
return await response.json();
}

async function fetchFileContent(path) {
const response = await fetch(`https://raw.githubusercontent.com/${repoOwner}/${repoName}/main/docs/${path}`);
return await response.text();
}

async function renderDocsTree(path = '', parentElement = document.getElementById('docs-tree')) {
const contents = await fetchRepoContents(path);
const ul = document.createElement('ul');
parentElement.appendChild(ul);

for (const item of contents) {
const li = document.createElement('li');
li.classList.add('list');

if (item.type === 'dir') {
li.textContent = item.name.replace(/-/g, ' ');
ul.appendChild(li);
await renderDocsTree(item.path.replace('docs/', ''), li);
} else if (item.type === 'file' && item.name.endsWith('.md')) {
const a = document.createElement('a');
a.href = '#';
a.textContent = item.name.replace(/-/g, ' ').replace('.md', '');
a.onclick = async () => {
const markdown = await fetchFileContent(item.path.replace('docs/', ''));
document.getElementById('docs-content').innerHTML = marked.parse(markdown);
};
li.appendChild(a);
ul.appendChild(li);
}
}
}

renderDocsTree();
</script>
</body>
</html>
16 changes: 13 additions & 3 deletions website/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ h2 {
color: #fab509;
}

h1 {
color: #fab509;
}

p {
font-size: 1.2em;
color: #fefefe;
line-height: 1.6;
}

hr {
border: none;
height: 3px;
Expand All @@ -139,14 +149,14 @@ hr {
padding-left: 20px;
}

.listt li::before {
/* .list li::before {
content: "•";
position: absolute;
left: 0;
top: 0;
}
} */

a {
color: #5895f0;
text-decoration: none;
}
}

0 comments on commit d4dc97b

Please sign in to comment.