aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bundle.gleam14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/bundle.gleam b/src/bundle.gleam
index 27cf34d..8781096 100644
--- a/src/bundle.gleam
+++ b/src/bundle.gleam
@@ -1,4 +1,8 @@
+import gleam/list
+import gleam/result
import wechat/object.{type JsObject}
+import wechat/page.{run_page}
+import wechat/app as weapp
import app/app
import app/pages/index/index
@@ -6,8 +10,8 @@ import app/components/basic/basic
pub type Constructor = fn() -> JsObject
-pub fn app() -> Constructor {
- app.app
+pub fn app() -> Result(Nil, Nil) {
+ app.app() |> weapp.run_app |> Ok
}
pub fn pages() -> List(#(String, Constructor)) {
@@ -17,3 +21,9 @@ pub fn pages() -> List(#(String, Constructor)) {
pub fn components() -> List(#(String, Constructor)) {
[#("basic", basic.component)]
}
+
+pub fn page(ps: List(#(String, Constructor)), p: String) -> Result(Nil, Nil) {
+ ps
+ |> list.find(fn(px) { px.0 == p })
+ |> result.try(fn(px) { px.1() |> run_page |> Ok})
+}