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

33 lines
706 B
Svelte
Raw Normal View History

2021-03-22 15:59:05 +01:00
<h1>__PROJECT_TITLE__</h1>
<style lang="less">
h1 {
color: red;
}
</style>
<script lang="typescript">
import { scrollToTop } from "svelte-scrollto"
import { location } from "../store"
export let url = ""
if (url) {
// ssr
let l = url.split("?")
$location = {
path: l[0],
search: l.length > 1 ? l[1] : "",
categoryPath: l[0].replace(/\/\d{4,99}[^\/]+$/, ""),
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>