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

76 lines
2.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 { generalInfo, location, currentLang } 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 = ""
2021-03-22 15:59:05 +01:00
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((location) => {
if (location.push) scrollToTop()
2021-03-22 15:59:05 +01:00
})
if (typeof window !== "undefined") console.log("App initialized")
</script>
2021-09-13 18:12:40 +02:00
<svelte:head>
{#if $generalInfo?.meta?.metaTitle}
<title>{$generalInfo?.meta?.metaTitle}</title>
{/if}
{#if $generalInfo?.meta?.metaDescription}
<meta name="description" content="{$generalInfo?.meta?.metaDescription}" />
{/if}
{#if $generalInfo?.meta?.metaKeywords}
<meta name="keywords" content="{$generalInfo?.meta?.metaKeywords.replaceAll(' ', '')}" />
{/if}
{#if $generalInfo?.person?.firstname || $generalInfo?.person?.lastname}
<meta
name="author"
content="{$generalInfo?.person?.firstname ? $generalInfo?.person?.firstname : ''} {$generalInfo?.person
?.lastname
? $generalInfo?.person?.lastname
: ''}"
/>
{/if}
{#if $generalInfo?.meta?.metaTagRobots}
<meta name="robots" content="{$generalInfo?.meta?.metaTagRobots}" />
{/if}
{#if $generalInfo?.media?.favicon}
<link rel="shortcut icon" type="image/x-icon" href="{$generalInfo?.media?.favicon.src}" />
{/if}
</svelte:head>
<Header />
2021-09-13 18:12:40 +02:00
<Router url="{url}">
<Route path="/" let:params>
<Home />
</Route>
<Route path="/*path" let:params>
<Content path="{params.path}" />
</Route>
</Router>
<Footer />
<style lang="less" global>
@import "./../css/main.less";
</style>