-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
97 lines (84 loc) · 2.9 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
<!DOCTYPE html>
<html lang="en">
<head>
<title>inxi</title>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<link href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css" rel="stylesheet">
<style>
body {
font-family: monospace;
}
.categories {
line-height: 1.3;
}
</style>
<script defer src="https://unpkg.com/lodash.orderby"></script>
<script defer src="https://unpkg.com/alpinejs"></script>
<script>
// Important stuff
const jsonPath = 'inxi.json'
// Stupid stuff
const module = {}
async function normalize() {
const json = await (await fetch(jsonPath)).json()
return json.map(normalizeCategory)
}
function normalizeCategory(category) {
return Object
.keys(category)
.sort()
.map(key => ({
title: cleanString(key),
categories: normalizeGroups(category[key])
}))[0]
}
function normalizeGroups(groups) {
return groups.map(group => (
Object
.keys(group)
.sort()
.map(key => ({
title: cleanString(key),
item: group[key]
}))
))
}
function getGroupsHighlight(group, index) {
const isGroupTitle = !index && !group.item
const highlightClass = isGroupTitle
? 'has-background-info-dark is-block mb-1'
: 'has-background-info'
return `${highlightClass} has-text-white px-1`
}
function cleanString(str) {
return str.split('#').slice(-1).pop()
}
</script>
</head>
<body>
<div
class="container is-max-desktop p-4 content"
x-data="{ inxi: [] }"
x-init="inxi = await normalize(); console.log(inxi)"
>
<template x-for="section in inxi">
<div class="sections block">
<h2 class="title mb-2" x-text="section.title"></h2>
<blockquote>
<template x-for="category in section.categories">
<div class="categories mb-1">
<template x-for="(group, index) in category">
<div class="groups is-inline">
<span x-text="group.title" x-bind:class="getGroupsHighlight(group, index)"></span>
<span x-text="group.item"></span>
</div>
</template>
</div>
</template>
</blockquote>
</div>
</template>
</div>
</body>
</html>