forked from logo94/getViafWorksById
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
131 lines (106 loc) · 4.39 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LabAIB</title>
<link rel="icon" type="image/x-icon" href="https://github.com/labaib/labaib.github.io/blob/main/img/202004298.png?raw=true">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<!-- Stili e Markdown -->
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.2.0/github-markdown.min.css">
<style>
body { height: 100%; width: 100%; }
h1 { margin-bottom: 1em; text-align: center; }
p { margin-bottom: 3em; text-align: center; }
pre { background-color: #E8E8E8; }
</style>
</head>
<body>
<!-- NAVBAR -->
<nav class="container navbar navbar-expand-lg navbar-light bg-transparent">
<a class="navbar-brand d-flex" href="/">
<h4 class="my-auto"><i>Lab</i></h4>
<img src="https://github.com/labaib/labaib.github.io/blob/main/img/202004298.png?raw=true" alt="" style="height: 2em;">
</a>
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" id="github_link" href="">
<i class="bi bi-github" style="font-size: 1.5rem;"></i>
</a>
</li>
</ul>
</nav>
<!-- BODY -->
<div class="container">
<div class="wrapper">
<div id="content" class="row py-4 px-5 w-100 justify-content-center">
<div id="readme"></div>
<div id="utterances" class="mt-4 w-100"></div>
</div>
</div>
</div>
<!-- SCRIPT -->
<script>
document.addEventListener("DOMContentLoaded", async () => {
const githubBtn = document.getElementById('github_link');
const readmeElement = document.getElementById('readme');
const utteranceElement = document.getElementById('utterances');
// 1. Estrai org/repo dall'URL
const [org, repo] = (() => {
const pathParts = window.location.pathname.split('/').filter(Boolean);
return [
window.location.hostname.split('.')[0],
pathParts[0] || 'labaib.github.io'
];
})();
document.title = `${repo} | ${org}'s Documentation`;
githubBtn.href = `https://github.com/${encodeURIComponent(org)}/${encodeURIComponent(repo)}`;
// Carica README.md
try {
const response = await fetch('./README.md');
if (!response.ok) throw new Error("HTTP error");
const text = await response.text();
// Sanitize del markdown
marked.setOptions({
sanitize: true,
breaks: true,
gfm: true
});
readmeElement.innerHTML = marked.parse(text).replace(/<table>/g, '<table class="table table-striped table-bordered mb-4">');
} catch (error) {
console.error("README load error:", error);
readmeElement.innerHTML = `
<div class="alert alert-warning mx-auto">
Documentazione non disponibile.
<a href="${githubBtn.href}">Vai al repository</a>
</div>
`;
}
// Utterances
const existing = utteranceElement.querySelector('script')
if (existing) existing.remove()
const script = document.createElement('script')
script.src = 'https://utteranc.es/client.js?v=' + Date.now()
script.async = true
script.setAttribute('repo', `${org}/${repo}`)
script.setAttribute('issue-term', 'title')
script.setAttribute('theme', 'github-light')
script.setAttribute('crossorigin', 'anonymous')
utteranceElement.appendChild(script)
// Fallback dopo 5 secondi
setTimeout(() => {
if (!utteranceElement.querySelector('.utterances-frame')) {
utteranceElement.innerHTML = `
<a href="https://github.com/${org}/${repo}/issues"
class="btn btn-outline-primary">
Commenta su GitHub Issues
</a>
`
}
}, 5000)
})
</script>
</body>
</html>