forked from cms/tibi-svelte-starter
init
This commit is contained in:
32
src/components/App.svelte
Normal file
32
src/components/App.svelte
Normal file
@@ -0,0 +1,32 @@
|
||||
<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>
|
||||
Reference in New Issue
Block a user