forked from scverse/rustar-aligner
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeader.astro
More file actions
163 lines (152 loc) · 5.22 KB
/
Header.astro
File metadata and controls
163 lines (152 loc) · 5.22 KB
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
---
import config from 'virtual:starlight/user-config';
import LanguageSelect from 'virtual:starlight/components/LanguageSelect';
import Search from 'virtual:starlight/components/Search';
import SiteTitle from 'virtual:starlight/components/SiteTitle';
import SocialIcons from 'virtual:starlight/components/SocialIcons';
import ThemeToggle from './ThemeToggle.astro';
const shouldRenderSearch =
config.pagefind || config.components.Search !== '@astrojs/starlight/components/Search.astro';
const REPO = 'scverse/rustar-aligner';
const BASE = import.meta.env.BASE_URL.replace(/\/?$/, '/');
const navLinks = [
{ label: 'Quick start', href: `${BASE}getting-started/quick-start/` },
{ label: 'Guides', href: `${BASE}guides/genome-index/` },
{ label: 'CLI', href: `${BASE}reference/cli-parameters/` },
{ label: 'Compatibility', href: `${BASE}reference/star-compatibility/` },
];
// Resolve the latest GitHub release at build time. Cached on globalThis so a
// single build only hits the GitHub API once across all page renders.
type Release = { label: string; url: string };
const g = globalThis as { __rustarRelease?: Promise<Release> };
g.__rustarRelease ??= (async () => {
const fallback: Release = { label: 'Releases', url: `https://github.com/${REPO}/releases` };
try {
const headers: Record<string, string> = { Accept: 'application/vnd.github+json' };
if (process.env.GITHUB_TOKEN) headers.Authorization = `Bearer ${process.env.GITHUB_TOKEN}`;
const res = await fetch(`https://api.github.com/repos/${REPO}/releases?per_page=1`, { headers });
if (!res.ok) return fallback;
const releases = (await res.json()) as Array<{ tag_name: string; html_url: string }>;
if (!Array.isArray(releases) || releases.length === 0) return fallback;
return { label: releases[0].tag_name, url: releases[0].html_url };
} catch {
return fallback;
}
})();
const { label: versionLabel, url: versionUrl } = await g.__rustarRelease;
---
<div class="header rustar-header">
<div class="title-wrapper sl-flex">
<SiteTitle />
<a class="version-pill sl-hidden md:sl-flex" href={versionUrl} aria-label={`Release notes for ${versionLabel}`}>{versionLabel}</a>
</div>
<nav class="top-nav sl-hidden md:sl-flex" aria-label="Primary">
{navLinks.map(({ label, href }) => (
<a href={href}>{label}</a>
))}
</nav>
<div class="sl-flex print:hidden search-cell">
{shouldRenderSearch && <Search />}
</div>
<div class="sl-hidden md:sl-flex print:hidden right-group">
<div class="sl-flex social-icons">
<SocialIcons />
</div>
<ThemeToggle />
<LanguageSelect />
</div>
</div>
<style>
@layer starlight.core {
.rustar-header {
display: flex;
gap: var(--sl-nav-gap);
justify-content: space-between;
align-items: center;
height: 100%;
}
.title-wrapper {
gap: 0.75rem;
align-items: center;
padding: 0.25rem;
margin: -0.25rem;
min-width: 0;
}
.right-group,
.social-icons {
gap: 1rem;
align-items: center;
}
.social-icons::after {
content: '';
height: 2rem;
border-inline-end: 1px solid var(--sl-color-gray-5);
}
.top-nav {
gap: 1.6rem;
align-items: center;
font-size: var(--sl-text-sm);
font-weight: 500;
}
.top-nav a {
color: var(--sl-color-gray-2);
text-decoration: none;
padding: 0.625rem 0.25rem;
border-bottom: 2px solid transparent;
transition: color 150ms ease, border-color 150ms ease;
}
.top-nav a:hover,
.top-nav a[aria-current="page"] {
color: var(--sl-color-white);
border-bottom-color: var(--sl-color-text-accent);
}
.version-pill {
font-family: var(--__sl-font-mono);
font-size: var(--sl-text-xs);
font-weight: 400;
color: var(--sl-color-gray-3);
padding: 0.25rem 0.65rem;
border: 1px solid var(--sl-color-gray-5);
border-radius: 999px;
letter-spacing: -0.01em;
white-space: nowrap;
align-items: center;
text-decoration: none;
transition: color 150ms ease, border-color 150ms ease;
}
.version-pill:hover {
color: var(--sl-color-white);
border-color: var(--sl-color-gray-3);
}
@media (min-width: 50rem) {
:global(:root[data-has-sidebar]) {
--__sidebar-pad: calc(2 * var(--sl-nav-pad-x));
}
:global(:root:not([data-has-toc])) {
--__toc-width: 0rem;
}
.rustar-header {
--__sidebar-width: max(0rem, var(--sl-content-inline-start, 0rem) - var(--sl-nav-pad-x));
--__main-column-fr: calc(
(
100% + var(--__sidebar-pad, 0rem) - var(--__toc-width, var(--sl-sidebar-width)) -
(2 * var(--__toc-width, var(--sl-nav-pad-x))) - var(--sl-content-inline-start, 0rem) -
var(--sl-content-width)
) / 2
);
display: grid;
grid-template-columns:
minmax(
calc(var(--__sidebar-width) + max(0rem, var(--__main-column-fr) - var(--sl-nav-gap))),
auto
)
auto
1fr
auto;
align-content: center;
}
.top-nav { justify-self: start; }
.search-cell { justify-self: end; }
}
}
</style>