Skip to content

Commit b75c9c9

Browse files
authored
Chore/vercel (#86)
* demo: add vercel * demo: config * chore: demo workflow
1 parent 9aa2835 commit b75c9c9

File tree

14 files changed

+47
-66
lines changed

14 files changed

+47
-66
lines changed

.github/workflows/demo.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ jobs:
1515
- uses: actions/checkout@v4
1616
with:
1717
fetch-depth: 0
18+
- name: Setup Node
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: 18
22+
cache: "npm"
1823
- name: Setup Rust
1924
uses: actions-rs/toolchain@v1
2025
with:
@@ -25,18 +30,13 @@ jobs:
2530
uses: jetli/[email protected]
2631
with:
2732
version: "v0.17.5"
28-
- name: Deploy GitHub Pages
33+
- name: Build
2934
run: |
3035
cd demo
3136
trunk build --release
32-
git worktree add gh-pages
33-
git config user.name "Deploy demo from CI"
34-
git config user.email ""
35-
cd gh-pages
36-
# Delete the ref to avoid keeping history.
37-
git update-ref -d refs/heads/gh-pages
38-
rm -rf *
39-
mv ../dist/* .
40-
git add .
41-
git commit -m "Deploy demo $GITHUB_SHA to gh-pages"
42-
git push --force --set-upstream origin gh-pages
37+
- name: Deploy
38+
run: npx vercel --token ${VERCEL_TOKEN} --prod
39+
env:
40+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
41+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
42+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}

demo/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Used
22

3-
Run the `trunk serve` command and then open the `http://127.0.0.1:6421/thaw` URL
3+
Run the `trunk serve` command and then open the `http://127.0.0.1:6421` URL
44

55
## Docs
66

demo/Trunk.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[build]
22
target = "index.html"
3-
public_url = "/thaw/"
3+
# public_url = "/thaw/"
44
# release = true
5-
filehash = false
5+
# filehash = false
66

77
[watch]
88
watch = ["../thaw", "./src", "../demo_markdown"]

demo/index.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77
<title>Thaw UI</title>
88
<link
99
rel="shortcut icon"
10-
href="/thaw/favicon.ico"
10+
href="/favicon.ico"
1111
type="image/x-icon"
1212
/>
1313
<link data-trunk rel="copy-file" href="./src/assets/svg/grid_dot.svg" />
1414
<link data-trunk rel="copy-file" href="./src/assets/favicon.ico" />
15-
<link data-trunk rel="copy-file" href="./src/assets/404.html" />
15+
<link
16+
data-trunk
17+
rel="copy-file"
18+
href="./src/assets/vercel/vercel.json"
19+
/>
1620
<link data-trunk rel="copy-file" href="../logo.svg" />
1721
</head>
1822
<body></body>

demo/src/app.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub fn App() -> impl IntoView {
1313
provide_meta_context();
1414

1515
view! {
16-
<Router base="/thaw" set_is_routing>
16+
<Router set_is_routing>
1717
<TheProvider>
1818
<TheRouter is_routing/>
1919
</TheProvider>
@@ -33,7 +33,7 @@ fn TheRouter(is_routing: RwSignal<bool>) -> impl IntoView {
3333
});
3434

3535
view! {
36-
<Routes base="/thaw".to_string()>
36+
<Routes>
3737
<Route path="/" view=Home/>
3838
<Route path="/guide" view=GuidePage>
3939
<Route path="/installation" view=InstallationMdPage/>

demo/src/assets/404.html

Lines changed: 0 additions & 30 deletions
This file was deleted.

demo/src/assets/vercel/vercel.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"rewrites": [
3+
{
4+
"source": "/(.*)",
5+
"destination": "/index.html"
6+
}
7+
]
8+
}

demo/src/components/demo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub struct DemoCode {
1313
pub fn Demo(demo_code: DemoCode, children: Children) -> impl IntoView {
1414
let theme = use_theme(Theme::light);
1515
let style = create_memo(move |_| {
16-
let mut style = String::from("background-image: url(/thaw/grid_dot.svg); background-repeat: repeat; background-size: 1.5rem; margin-top: 1rem; padding: 1rem; border-top-left-radius: 0.5rem; border-top-right-radius: 0.5rem;");
16+
let mut style = String::from("background-image: url(/grid_dot.svg); background-repeat: repeat; background-size: 1.5rem; margin-top: 1rem; padding: 1rem; border-top-left-radius: 0.5rem; border-top-right-radius: 0.5rem;");
1717
theme.with(|theme| {
1818
if theme.common.color_scheme == "dark" {
1919
style.push_str("border: 1px solid #383f52;");

demo/src/components/site_header.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub fn SiteHeader() -> impl IntoView {
126126
let navigate = use_navigate();
127127
navigate("/", Default::default());
128128
}>
129-
<img src="/thaw/logo.svg" style="width: 36px"/>
129+
<img src="/logo.svg" style="width: 36px"/>
130130
<div class="demo-name">
131131
"Thaw UI"
132132
</div>
@@ -234,10 +234,10 @@ fn use_menu_value(change_theme: Callback<()>) -> RwSignal<String> {
234234

235235
let menu_value = create_rw_signal({
236236
let mut pathname = loaction.pathname.get_untracked();
237-
if pathname.starts_with("/thaw/components/") {
238-
pathname.drain(17..).collect()
239-
} else if pathname.starts_with("/thaw/guide/") {
237+
if pathname.starts_with("/components/") {
240238
pathname.drain(12..).collect()
239+
} else if pathname.starts_with("/guide/") {
240+
pathname.drain(7..).collect()
241241
} else {
242242
String::new()
243243
}
@@ -256,10 +256,10 @@ fn use_menu_value(change_theme: Callback<()>) -> RwSignal<String> {
256256
menu.iter()
257257
.any(|group| group.children.iter().any(|item| &item.value == name))
258258
}) {
259-
if !pathname.eq(&format!("/thaw/guide/{name}")) {
259+
if !pathname.eq(&format!("/guide/{name}")) {
260260
navigate(&format!("/guide/{name}"), Default::default());
261261
}
262-
} else if !pathname.eq(&format!("/thaw/components/{name}")) {
262+
} else if !pathname.eq(&format!("/components/{name}")) {
263263
navigate(&format!("/components/{name}"), Default::default());
264264
}
265265
});

demo/src/pages/components.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ pub fn ComponentsPage() -> impl IntoView {
1212
let select_name = create_rw_signal(String::new());
1313
create_effect(move |_| {
1414
let mut pathname = loaction.pathname.get();
15-
let name = if pathname.starts_with("/thaw/components/") {
16-
pathname.drain(17..).collect()
15+
let name = if pathname.starts_with("/components/") {
16+
pathname.drain(12..).collect()
1717
} else {
1818
String::new()
1919
};
@@ -22,7 +22,7 @@ pub fn ComponentsPage() -> impl IntoView {
2222

2323
_ = select_name.watch(move |name| {
2424
let pathname = loaction.pathname.get_untracked();
25-
if !pathname.eq(&format!("/thaw/components/{name}")) {
25+
if !pathname.eq(&format!("/components/{name}")) {
2626
navigate(&format!("/components/{name}"), Default::default());
2727
}
2828
});

0 commit comments

Comments
 (0)