tibi-svelte-starter/src/components/App.svelte

50 lines
1.1 KiB
Svelte
Raw Normal View History

2021-12-08 12:56:19 +01:00
<script lang="ts">
import { Router, Route } from "svelte-routing"
2021-03-22 15:59:05 +01:00
import { scrollToTop } from "svelte-scrollto"
import { location } from "../store"
import Home from "./routes/Home.svelte"
2021-09-13 18:12:40 +02:00
import Content from "./routes/Content.svelte"
2021-03-22 15:59:05 +01:00
import Header from "./widgets/Header.svelte"
import Footer from "./widgets/Footer.svelte"
2021-03-22 15:59:05 +01:00
export let url = ""
if (url) {
// ssr
let l = url.split("?")
$location = {
path: l[0],
search: l.length > 1 ? l[1] : "",
push: false,
pop: false,
}
}
// scroll to top on new site
location.subscribe((l) => {
if (l.push) scrollToTop()
})
if (typeof window !== "undefined") console.log("App initialized")
</script>
2021-09-13 18:12:40 +02:00
<Header />
2021-09-13 18:12:40 +02:00
<div>
2021-09-13 18:12:40 +02:00
<Router url="{url}">
<Route path="/" let:params>
<Home />
</Route>
2021-09-13 18:12:40 +02:00
<Route path="/*path" let:params>
<Content path="/{params.path}" />
</Route>
</Router>
2021-09-14 13:26:35 +02:00
</div>
<Footer />
<style lang="less" global>
@import "./../css/main.less";
</style>