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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
import "./index.css"
import { Title, Meta } from "@solidjs/meta"
import { createAsync } from "@solidjs/router"
import { Header } from "~/component/header"
import { Footer } from "~/component/footer"
import { Legal } from "~/component/legal"
import { changelog } from "~/lib/changelog"
import type { HighlightGroup } from "~/lib/changelog"
import { For, Show, createSignal } from "solid-js"
import { useI18n } from "~/context/i18n"
import { useLanguage } from "~/context/language"
import { LocaleLinks } from "~/component/locale-links"
function formatDate(dateString: string, locale: string) {
const date = new Date(dateString)
return date.toLocaleDateString(locale, {
year: "numeric",
month: "short",
day: "numeric",
})
}
function ReleaseItem(props: { item: string }) {
const parts = () => {
const match = props.item.match(/^(.+?)(\s*\(@([\w-]+)\))?$/)
if (match) {
return {
text: match[1],
username: match[3],
}
}
return { text: props.item, username: undefined }
}
return (
<li>
<span>{parts().text}</span>
<Show when={parts().username}>
<a data-slot="author" href={`https://github.com/${parts().username}`} target="_blank" rel="noopener noreferrer">
(@{parts().username})
</a>
</Show>
</li>
)
}
function HighlightSection(props: { group: HighlightGroup }) {
return (
<div data-component="highlight">
<h4>{props.group.source}</h4>
<hr />
<For each={props.group.items}>
{(item) => (
<div data-slot="highlight-item">
<p data-slot="title">{item.title}</p>
<p>{item.description}</p>
<Show when={item.media.type === "video"}>
<video src={item.media.src} controls autoplay loop muted playsinline />
</Show>
<Show when={item.media.type === "image"}>
<img
src={item.media.src}
alt={item.title}
width={(item.media as { width: string }).width}
height={(item.media as { height: string }).height}
/>
</Show>
</div>
)}
</For>
</div>
)
}
function CollapsibleSection(props: { section: { title: string; items: string[] } }) {
const [open, setOpen] = createSignal(false)
return (
<div data-component="collapsible-section">
<button data-slot="toggle" onClick={() => setOpen(!open())}>
<span data-slot="icon">{open() ? "▾" : "▸"}</span>
<span>{props.section.title}</span>
</button>
<Show when={open()}>
<ul>
<For each={props.section.items}>{(item) => <ReleaseItem item={item} />}</For>
</ul>
</Show>
</div>
)
}
function CollapsibleSections(props: { sections: { title: string; items: string[] }[] }) {
return (
<div data-component="collapsible-sections">
<For each={props.sections}>{(section) => <CollapsibleSection section={section} />}</For>
</div>
)
}
export default function Changelog() {
const i18n = useI18n()
const language = useLanguage()
const data = createAsync(() => changelog())
const releases = () => data() ?? []
return (
<main data-page="changelog">
<Title>{i18n.t("changelog.title")}</Title>
<LocaleLinks path="/changelog" />
<Meta name="description" content={i18n.t("changelog.meta.description")} />
<div data-component="container">
<Header />
<div data-component="content">
<section data-component="changelog-hero">
<h1>{i18n.t("changelog.hero.title")}</h1>
<p>{i18n.t("changelog.hero.subtitle")}</p>
</section>
<section data-component="releases">
<Show when={releases().length === 0}>
<p>
{i18n.t("changelog.empty")}{" "}
<a href={language.route("/changelog.json")}>{i18n.t("changelog.viewJson")}</a>
</p>
</Show>
<For each={releases()}>
{(release) => {
return (
<article data-component="release">
<header>
<div data-slot="version">
<a href={release.url} target="_blank" rel="noopener noreferrer">
{release.tag}
</a>
</div>
<time dateTime={release.date}>{formatDate(release.date, language.tag(language.locale()))}</time>
</header>
<div data-slot="content">
<Show when={release.highlights.length > 0}>
<div data-component="highlights">
<For each={release.highlights}>{(group) => <HighlightSection group={group} />}</For>
</div>
</Show>
<Show when={release.highlights.length > 0 && release.sections.length > 0}>
<CollapsibleSections sections={release.sections} />
</Show>
<Show when={release.highlights.length === 0}>
<For each={release.sections}>
{(section) => (
<div data-component="section">
<h3>{section.title}</h3>
<ul>
<For each={section.items}>{(item) => <ReleaseItem item={item} />}</For>
</ul>
</div>
)}
</For>
</Show>
</div>
</article>
)
}}
</For>
</section>
</div>
<Footer />
</div>
<Legal />
</main>
)
}
|