Skip to content

Commit 3c649f6

Browse files
committed
fix(ci): github workflows docs
1 parent ff3cd1e commit 3c649f6

File tree

8 files changed

+51
-36
lines changed

8 files changed

+51
-36
lines changed

.github/workflows/docs.yml

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Q|ery. Web Docs
1+
name: Web Docs
22

33
on:
44
push:
@@ -8,6 +8,7 @@ on:
88
- "**[0-9]+.[0-9]+.[0-9]+*"
99
paths:
1010
- examples/docs/**
11+
- .github/workflows/docs.yml
1112

1213
env:
1314
CARGO_TERM_COLOR: always
@@ -29,28 +30,19 @@ jobs:
2930
- name: Rust Cache Action
3031
uses: Swatinem/rust-cache@v2
3132

32-
- name: Assets Cache
33+
- name: Cache
3334
id: query-cache
3435
uses: actions/cache@v4
3536
with:
36-
path: .query/.cache
37+
path: examples/docs/.query/.cache
3738
key: query-cache-${{ github.run_id }}
3839
restore-keys: query-cache
3940

40-
- name: Set token
41-
env:
42-
QUERY_WEB_PRIVATE_TOKEN: ${{ secrets.QUERY_WEB_PRIVATE_TOKEN }}
43-
run: |
44-
echo "[default] $QUERY_WEB_PRIVATE_TOKEN" > .query/.token
45-
46-
- name: Set remote URL
47-
run: |
48-
sed -i "s|http://localhost:3000|https://qery.io|" .query/Query.toml
49-
5041
- name: Use pnpm
5142
uses: pnpm/action-setup@v4
5243
with:
5344
version: 10
45+
run_install: false
5446

5547
- name: Use Node.js ${{ matrix.node-version }}
5648
uses: actions/setup-node@v4
@@ -59,18 +51,43 @@ jobs:
5951
cache: "pnpm"
6052

6153
- name: Install dependencies
62-
run: pnpm install
54+
run: |
55+
cd examples/docs
56+
pnpm install
6357
6458
- name: Create docs
6559
env:
6660
RUST_BACKTRACE: full
6761
RUST_LOG: info
62+
run: |
63+
cargo run --package query-docs -- --input examples/docs/docs --output examples/docs/dist/docs
64+
65+
- name: Debug dist directory
66+
run: |
67+
find examples/docs/dist/docs -type f | sort
68+
69+
- name: Set token
70+
env:
71+
QUERY_WEB_PRIVATE_TOKEN: ${{ secrets.QUERY_WEB_PRIVATE_TOKEN }}
72+
run: |
73+
cd examples/docs
74+
echo "[default] $QUERY_WEB_PRIVATE_TOKEN" > .query/.token
75+
76+
- name: Set remote URL
6877
run: |
6978
cd examples/docs
70-
pnpm query task docs
79+
sed -i "s|http://localhost:3000|https://qery.io|" .query/Query.toml
7180
7281
- name: Deploy to qery.io
7382
run: |
7483
cd examples/docs
75-
pnpm query task deploy
76-
pnpm query asset dist
84+
./node_modules/.bin/tailwindcss -i ./docs/styles.css -o ./dist/docs/styles.css
85+
./node_modules/.bin/query asset dist
86+
./node_modules/.bin/query function src/pages/docs/get.index.tsx
87+
./node_modules/.bin/query function src/pages/docs/\[slug\]/get.index.tsx
88+
./node_modules/.bin/query function src/pages/docs/\[slug\]/\[slug\]/get.index.tsx
89+
90+
- name: Cache content
91+
run: |
92+
cd examples/docs
93+
cat .query/.cache

examples/docs/docs/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>{{title}} - Documentation</title>
7-
<base href="http://localhost:3000/docs/" />
7+
<base href="__BASE_URL__/docs/" />
88
<meta name="description" content="{{description}}" />
99
<link rel="stylesheet" href="__STYLES_CSS__" />
1010
</head>

examples/docs/docs/templates/left-navigation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ <h2 class="font-cal mb-8 pb-4 border-b border-slate-200 text-slate-900 dark:bord
1616
<ul class="toc-list space-y-4 dark:text-white">
1717
{% for group in toc.items %}
1818
<li class="pb-4 border-b border-slate-200 space-y-2 dark:border-slate-700">
19-
<h3 class="font-cal text-sm">{{ group.group }}</h3>
19+
<h3 class="font-cal text-sm">{{ group.name }}</h3>
2020
<ul class="border-l border-slate-400 pl-4">
2121
{% for item in group.items %}
2222
<li class="toc-item{% if item.url == navigation.current.url %} active font-semibold{% endif %}">

examples/docs/docs/templates/page-footer.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<!-- -->2025<!-- -->. All rights reserved.
1515
</p>
1616
<div class="flex gap-4">
17-
<a class="group" href="#"
17+
<a class="group" href="https://github.com/gc-victor/query"
1818
><span class="sr-only">Follow us on GitHub</span
1919
><svg
2020
viewBox="0 0 20 20"
@@ -23,7 +23,7 @@
2323
>
2424
<title>Follow us on GitHub</title>
2525
<use href="#icon-github-logo" /></svg></a
26-
><a class="group" href="#"
26+
><a class="group" href="https://qery.io/discord"
2727
><span class="sr-only">Join our Discord server</span
2828
><svg
2929
viewBox="0 0 20 20"

examples/docs/docs/templates/top-navigation.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
></path>
3434
</svg>
3535
</label>
36-
<a class="group" href="#"
36+
<a class="group" href="https://github.com/gc-victor/query"
3737
><span class="sr-only">Follow us on GitHub</span
3838
><svg
3939
viewBox="0 0 20 20"
@@ -42,7 +42,7 @@
4242
>
4343
<title>Follow us on GitHub</title>
4444
<use href="#icon-github-logo" /></svg></a
45-
><a class="group" href="#"
45+
><a class="group" href="https://qery.io/discord"
4646
><span class="sr-only">Join our Discord server</span
4747
><svg
4848
viewBox="0 0 20 20"

examples/docs/src/pages/docs/[slug]/[slug]/get.index.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
export async function handleRequest(req: Request) {
22
const url = new URL(req.url);
3-
const dir = url.pathname.split("/").slice(0, -2).pop();
43
const subdir = url.pathname.split("/").slice(0, -1).pop();
54
const slug = url.pathname.split("/").pop();
65

76
const db = new Database("query_asset.sql");
87
const result: { data: AllowSharedBufferSource }[] = db.query_cache(
98
"SELECT data FROM asset WHERE name = $1",
10-
[`dist/${dir}/${subdir}/${slug}`],
9+
[`dist/docs/${subdir}/${slug}`],
1110
10000,
1211
);
1312

@@ -25,7 +24,7 @@ export async function handleRequest(req: Request) {
2524

2625
const html = new TextDecoder().decode((result404[0] as { data: AllowSharedBufferSource }).data);
2726

28-
return new Response(html.replace("__STYLES_CSS__", styles), {
27+
return new Response(html.replace("__STYLES_CSS__", styles).replace("__BASE_URL__", url.origin), {
2928
status: 404,
3029
headers: { "Content-Type": "text/html; charset=utf-8", "Query-Cache-Control": "max-age=3600000" },
3130
});
@@ -44,5 +43,5 @@ export async function handleRequest(req: Request) {
4443
headers["Query-Cache-Control"] = "max-age=3600000";
4544
}
4645

47-
return new Response(html.replace("__STYLES_CSS__", styles), { status: 200, headers });
46+
return new Response(html.replace("__STYLES_CSS__", styles).replace("__BASE_URL__", url.origin), { status: 200, headers });
4847
}

examples/docs/src/pages/docs/[slug]/get.index.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
export async function handleRequest(req: Request) {
22
const url = new URL(req.url);
3-
const dir = url.pathname.split("/").slice(0, -1).pop();
43
const slug = url.pathname.split("/").pop();
54

65
const db = new Database("query_asset.sql");
7-
const result = db.query("SELECT data FROM asset WHERE name = $1", [`dist/${dir}/${slug}`]);
6+
const result = db.query("SELECT data FROM asset WHERE name = $1", [`dist/docs/${slug}`]);
87

98
const styles_result = db.query("SELECT name_hashed FROM asset WHERE name = ?", ["dist/docs/styles.css"]) as {
109
name_hashed: string;
@@ -19,10 +18,10 @@ export async function handleRequest(req: Request) {
1918
}
2019

2120
const html = new TextDecoder().decode((result404[0] as { data: AllowSharedBufferSource }).data);
22-
23-
return new Response(html.replace("__STYLES_CSS__", styles), {
21+
22+
return new Response(html.replace("__STYLES_CSS__", styles).replace("__BASE_URL__", url.origin), {
2423
status: 404,
25-
headers: { "Content-Type": "text/html; charset=utf-8", "Query-Cache-Control": "max-age=3600000" },
24+
headers: { "Content-Type": "text/html; charset=utf-8" },
2625
});
2726
}
2827

@@ -39,5 +38,5 @@ export async function handleRequest(req: Request) {
3938
headers["Query-Cache-Control"] = "max-age=3600000";
4039
}
4140

42-
return new Response(html.replace("__STYLES_CSS__", styles), { status: 200, headers });
41+
return new Response(html.replace("__STYLES_CSS__", styles).replace("__BASE_URL__", url.origin), { status: 200, headers });
4342
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export async function handleRequest(req: Request) {
2-
const url = process.env.QUERY_APP_ENV === "development" ? "http://localhost:3000" : "https://qery.io";
3-
4-
return Response.redirect(`${url}/docs/introduction.html`, 301);
2+
const url = new URL(req.url)
3+
4+
return Response.redirect(`${url.origin}/docs/introduction.html`, 301);
55
}

0 commit comments

Comments
 (0)