Skip to content

Commit 411db0b

Browse files
authored
Add Netlify badge (#2065)
* Only check GitHub token for docs build when update needed * Add Netlify badge * Use link
1 parent 39f9b2f commit 411db0b

File tree

5 files changed

+38
-21
lines changed

5 files changed

+38
-21
lines changed

docs/.vitepress/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import zh from "./zh";
44
import ja from "./ja";
55
import shared from "./shared";
66
import { transformerTwoslash } from "@shikijs/vitepress-twoslash";
7-
import { ModuleKind, ModuleResolutionKind } from "typescript";
7+
import { ModuleResolutionKind } from "typescript";
88

99
// https://vitepress.dev/reference/site-config
1010
export default defineConfig({

docs/.vitepress/en.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export default defineConfig({
139139
],
140140
footer: {
141141
message:
142-
'Released under the <a href="https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript/LICENSE">MIT License</a>.',
142+
'Released under the <a href="https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript/LICENSE">MIT License</a>. Powered by <a href="https://netlify.com">Netlify</a>.',
143143
},
144144
},
145145
});

docs/.vitepress/shared.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const shared: UserConfig = {
2626
themeConfig: {
2727
siteTitle: false,
2828
logo: "/assets/openapi-ts.svg",
29-
outline: 'deep',
29+
outline: "deep",
3030
search: {
3131
provider: "algolia",
3232
options: {

docs/.vitepress/theme/CustomLayout.vue

+23-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const { Layout } = DefaultTheme;
3939
</a></template
4040
>
4141

42-
<!-- Silver sponsor logos -->
42+
<!-- Sidebar sponsors -->
4343
<template #sidebar-nav-after>
4444
<div class="sidenav-sponsors">
4545
<h5>Gold Sponsors</h5>
@@ -58,6 +58,9 @@ const { Layout } = DefaultTheme;
5858
</a>
5959
</li>
6060
</ul>
61+
<p class="sidebar-hosting">
62+
Powered by <a href="https://netlify.com">Netlify</a>
63+
</p>
6164
</div>
6265
</template>
6366
</Layout>
@@ -147,6 +150,25 @@ const { Layout } = DefaultTheme;
147150
height: 3rem;
148151
width: auto;
149152
}
153+
154+
.sidebar-hosting {
155+
color: var(--vp-c-text-3);
156+
font-size: 0.75rem;
157+
font-weight: 500;
158+
letter-spacing: 0.0625em;
159+
margin-block-start: 2rem;
160+
text-transform: uppercase;
161+
162+
a {
163+
color: var(--vp-c-brand-1);
164+
text-decoration: underline;
165+
166+
&:hover,
167+
&:focus-visible {
168+
color: var(--vp-c-brand-2);
169+
}
170+
}
171+
}
150172
</style>
151173

152174
<style>

docs/scripts/update-contributors.js

+12-17
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ const data = JSON.parse(fs.readFileSync(CONTRIBUTORS_JSON, "utf8"));
77

88
const ONE_WEEK = 1000 * 60 * 60 * 24;
99

10-
const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
11-
if (!GITHUB_TOKEN) {
12-
throw new Error(
13-
'GITHUB_TOKEN not set! Create a token with "read:user" scope and set as an environment variable.\nhttps://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic',
14-
);
10+
function getGitHubToken() {
11+
const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
12+
if (!GITHUB_TOKEN) {
13+
throw new Error(
14+
'GITHUB_TOKEN not set! Create a token with "read:user" scope and set as an environment variable.\nhttps://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic',
15+
);
16+
}
17+
return GITHUB_TOKEN;
1518
}
1619

1720
class UserFetchError extends Error {
@@ -37,7 +40,7 @@ async function fetchUserInfo(username) {
3740
const res = await fetch(`https://api.github.com/users/${username}`, {
3841
headers: {
3942
Accept: "application/vnd.github+json",
40-
Authorization: `Bearer ${GITHUB_TOKEN}`,
43+
Authorization: `Bearer ${getGitHubToken()}`,
4144
"X-GitHub-Api-Version": "2022-11-28",
4245
},
4346
});
@@ -189,19 +192,14 @@ const CONTRIBUTORS = {
189192

190193
async function main() {
191194
let i = 0;
192-
const total = Object.values(CONTRIBUTORS).reduce(
193-
(total, next) => total + next.size,
194-
0,
195-
);
195+
const total = Object.values(CONTRIBUTORS).reduce((total, next) => total + next.size, 0);
196196
await Promise.all(
197197
Object.entries(CONTRIBUTORS).map(async ([repo, contributors]) => {
198198
data[repo] ??= [];
199199
for (const username of [...contributors]) {
200200
i++;
201201
// skip profiles that have been updated within the past week
202-
const { lastFetch } = data[repo].find(
203-
(u) => u.username === username,
204-
) ?? { lastFetch: 0 };
202+
const { lastFetch } = data[repo].find((u) => u.username === username) ?? { lastFetch: 0 };
205203
if (Date.now() - lastFetch < ONE_WEEK) {
206204
// biome-ignore lint/suspicious/noConsoleLog: this is a script
207205
console.log(`[${i}/${total}] (Skipped ${username})`);
@@ -219,10 +217,7 @@ async function main() {
219217
upsert(data[repo], userData);
220218
// biome-ignore lint/suspicious/noConsoleLog: this is a script
221219
console.log(`[${i}/${total}] Updated for ${username}`);
222-
fs.writeFileSync(
223-
new URL("../data/contributors.json", import.meta.url),
224-
JSON.stringify(data),
225-
); // update file while fetching (sync happens safely in between fetches)
220+
fs.writeFileSync(new URL("../data/contributors.json", import.meta.url), JSON.stringify(data)); // update file while fetching (sync happens safely in between fetches)
226221
} catch (err) {
227222
if (err instanceof UserFetchError && err.notFound) {
228223
console.warn(`[${i}/${total}] (Skipped ${username}, not found)`);

0 commit comments

Comments
 (0)