Skip to content

Commit

Permalink
Implement 'add' functionality for template
Browse files Browse the repository at this point in the history
Signed-off-by: Darwin Boersma <darwin@sadlark.com>
  • Loading branch information
ogghead committed Dec 7, 2024
1 parent 791ef83 commit 6aa9380
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
8 changes: 4 additions & 4 deletions templates/leptos-ssr/content/spin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = ["{{authors}}"]
description = "{{project-description}}"

[[trigger.http]]
route = "/..."
route = "{{http-path}}..."
component = "{{project-name | kebab_case}}"

[component.{{project-name | kebab_case}}]
Expand All @@ -19,9 +19,9 @@ command = "cargo leptos build --release && LEPTOS_OUTPUT_NAME={{project-name | s
watch = ["src/**/*.rs", "Cargo.toml"]

[[trigger.http]]
route = "/pkg/..."
component = "pkg"
route = "{{http-path}}pkg/..."
component = "{{project-name | kebab_case}}-pkg"

[component.pkg]
[component.{{project-name | kebab_case}}-pkg]
source = { url = "https://github.com/fermyon/spin-fileserver/releases/download/v0.1.0/spin_static_fs.wasm", digest = "sha256:96c76d9af86420b39eb6cd7be5550e3cb5d4cc4de572ce0fd1f6a29471536cb4" }
files = [{ source = "target/site/pkg", destination = "/" }]
20 changes: 20 additions & 0 deletions templates/leptos-ssr/metadata/snippets/component.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[[trigger.http]]
route = "{{http-path}}..."
component = "{{project-name | kebab_case}}"

[component.{{project-name | kebab_case}}]
source = "{{output-path}}/target/wasm32-wasip1/release/{{project-name | snake_case}}.wasm"
allowed_outbound_hosts = []
key_value_stores = ["default"]
[component.{{project-name | kebab_case}}.build]
command = "cargo leptos build --release && LEPTOS_OUTPUT_NAME={{project-name | snake_case}} cargo build --lib --target wasm32-wasip1 --release --no-default-features --features ssr"
workdir = "{{output-path}}"
watch = ["src/**/*.rs", "Cargo.toml"]

[[trigger.http]]
route = "{{http-path}}pkg/..."
component = "{{project-name | kebab_case}}-pkg"

[component.{{project-name | kebab_case}}-pkg]
source = { url = "https://github.com/fermyon/spin-fileserver/releases/download/v0.1.0/spin_static_fs.wasm", digest = "sha256:96c76d9af86420b39eb6cd7be5550e3cb5d4cc4de572ce0fd1f6a29471536cb4" }
files = [{ source = "{{output-path}}/target/site/pkg", destination = "/" }]
7 changes: 6 additions & 1 deletion templates/leptos-ssr/metadata/spin-template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ tags = ["http", "rust", "leptos"]

[parameters]
project-description = { type = "string", prompt = "Description", default = "" }
http-path = { type = "string", prompt = "HTTP path", default = "/...", pattern = "^/\\S*$" }
http-path = { type = "string", prompt = "HTTP path", default = "/", pattern = "^/\\S*$" }

[add_component]
skip_files = ["spin.toml"]
[add_component.snippets]
component = "component.txt"

0 comments on commit 6aa9380

Please sign in to comment.