Skip to content

Commit

Permalink
Add reference index
Browse files Browse the repository at this point in the history
  • Loading branch information
jrodewig committed Aug 9, 2024
1 parent 6061fb6 commit 85defc6
Showing 1 changed file with 135 additions and 0 deletions.
135 changes: 135 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<!doctype html>
<html class="default" lang="en">

<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="IE=edge" />
<title>Fauna v10 JavaScript driver - API reference</title>
<meta name="description" content="API reference documentation for the Fauna v10 JavaScript driver" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
body {
font-family: Arial, sans-serif;
line-height: 1.6;
color: #333;
max-width: 800px;
margin: 0 auto;
padding: 20px;
}

h1 {
color: #2c3e50;
border-bottom: 2px solid #3498db;
padding-bottom: 10px;
}

a {
color: #3498db;
text-decoration: none;
}

a:hover {
text-decoration: underline;
}

table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}

th,
td {
padding: 12px;
text-align: left;
border-bottom: 1px solid #ddd;
}

th {
background-color: #f2f2f2;
font-weight: bold;
}

tr:hover {
background-color: #f5f5f5;
}

p {
margin-bottom: 20px;
}
</style>
</head>

<body>
<h1>Fauna v10 JavaScript driver - API reference</h1>
<p>This site contains API reference documentation for the
<a href="https://github.com/fauna/fauna-js">Fauna v10 JavaScript driver</a>.<br>
The documentation is generated using TypeDoc.
</p>
<p>
For examples and tutorials, see the
<a href="https://github.com/fauna/fauna-js">driver README</a> and
the
<a href="https://docs.fauna.com/fauna/current/build/drivers/js-client/">Fauna docs</a>.
</p>
<script>
(async () => {
const branch = 'gh-pages';
const response = await fetch(`https://api.github.com/repos/fauna/fauna-js/contents?ref=${branch}`);
const data = await response.json();
let tableRows = [];
let latestTarget = '';

for (let item of data) {
if (item.name === 'latest' && item.type === 'symlink') {
const symlinkResponse = await fetch(item.url);
const symlinkData = await symlinkResponse.json();
latestTarget = symlinkData.target.replace('https://github.com/fauna/fauna-js/tree/gh-pages/', '');
}
}

for (let item of data) {
if (item.type === 'dir') {
const url = item.html_url.replace('https://github.com/fauna/fauna-js/tree/gh-pages/', 'https://fauna.github.io/fauna-js/');

let displayName = item.name;

if (item.name === latestTarget) {
displayName += ' (latest)';
}

tableRows.push({
name: displayName,
url: url,
});
}
}

tableRows.sort((a, b) => {
if (a.name.includes('(Latest)')) return -1;
if (b.name.includes('(Latest)')) return 1;
return b.name.localeCompare(a.name, undefined, { numeric: true, sensitivity: 'base' });
});

let htmlString = `
<table>
<tr>
<th>Version</th>
</tr>
`;

for (let row of tableRows) {
htmlString += `
<tr>
<td><a href="${row.url}">${row.name}</a></td>
</tr>
`;
}

htmlString += '</table>';
document.body.insertAdjacentHTML('beforeend', htmlString);
})()
</script>
</body>

</html>

0 comments on commit 85defc6

Please sign in to comment.