Skip to content

Commit

Permalink
update vue3 tailwind example
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Sarvarov committed Jun 12, 2024
1 parent 0cf7f3d commit 75bc28d
Show file tree
Hide file tree
Showing 22 changed files with 3,186 additions and 187 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func main() {
// but you are free to use some frameworks like Gorilla Mux or Chi.
mux := http.NewServeMux()

mux.Handle("/", i.Middleware(homeHandler(i)))
mux.Handle("/home", i.Middleware(homeHandler(i)))
}

func homeHandler(i *inertia.Inertia) http.Handler {
Expand Down Expand Up @@ -92,7 +92,7 @@ Create `root.html` template:
</html>
```

You can also find more examples in an [examples folder](./examples) or in section above.
You can also find more examples and starter kits in [examples folder](./examples) or in section above.

### More examples

Expand Down
3 changes: 0 additions & 3 deletions examples/vue3/public/mix-manifest.json

This file was deleted.

12 changes: 0 additions & 12 deletions examples/vue3/resources/js/Pages/Home/Index.vue

This file was deleted.

2 changes: 1 addition & 1 deletion examples/vue3/go.mod → examples/vue3_tailwind/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/romsar/gonertia/examples/vue3
module github.com/romsar/gonertia/examples/vue3_tailwind

go 1.22

Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions examples/vue3_tailwind/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["resources/js/*"]
}
},
"exclude": ["node_modules", "public/build"]
}
17 changes: 16 additions & 1 deletion examples/vue3/main.go → examples/vue3_tailwind/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ func main() {
}

mux := http.NewServeMux()
mux.Handle("/", i.Middleware(homeHandler(i)))

mux.Handle("/home", i.Middleware(homeHandler(i)))
mux.Handle("/secondary", i.Middleware(secondaryHandler(i)))
mux.Handle("/build/", http.StripPrefix("/build/", http.FileServer(http.Dir("./public/build"))))

http.ListenAndServe(":3000", mux)
Expand All @@ -37,6 +39,19 @@ func homeHandler(i *inertia.Inertia) http.Handler {
return http.HandlerFunc(fn)
}

func secondaryHandler(i *inertia.Inertia) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
err := i.Render(w, r, "Home/Secondary")

if err != nil {
handleServerErr(w, err)
return
}
}

return http.HandlerFunc(fn)
}

func handleServerErr(w http.ResponseWriter, err error) {
log.Printf("http error: %s\n", err)
w.WriteHeader(http.StatusInternalServerError)
Expand Down
Loading

0 comments on commit 75bc28d

Please sign in to comment.