backend and api endpoints

This commit is contained in:
2023-07-14 11:58:27 +00:00
parent 90b4c95cd8
commit 897b9ae2cf
27 changed files with 1140 additions and 20 deletions

View File

@@ -0,0 +1,52 @@
<script>
import { navigate } from "svelte-routing"
</script>
<div class="not-found">
<div class="content">
<h1>404</h1>
<h2>Seite nicht gefunden</h2>
<p>
Die gesuchte Seite wurde möglicherweise entfernt, ihr Name wurde geändert oder sie ist vorübergehend nicht
verfügbar.
</p>
<button on:click="{() => navigate('/')}" class="back-home">Zurück zur Startseite</button>
</div>
</div>
<style lang="less">
@import "../assets/css/main.less";
.not-found {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
.content {
text-align: center;
padding: 2rem;
background-color: rgba(255, 255, 255, 0.9);
h1 {
font-size: 6rem;
margin-bottom: 2rem;
}
h2 {
font-size: 2rem;
margin-bottom: 1rem;
}
p {
margin-bottom: 2rem;
}
.back-home {
text-decoration: none;
border: 1px solid black;
padding: 0.5rem 1rem;
transition: background-color 0.2s, color 0.2s;
}
}
}
</style>

View File

@@ -0,0 +1,5 @@
<script lang="ts">
export let row: Row
</script>
<stlye lang="less"></stlye>

View File

@@ -0,0 +1,8 @@
<script lang="ts">
export let row: Row
</script>
<div></div>
<style lang="less">
</style>

View File

@@ -0,0 +1,27 @@
<script lang="ts">
import { init } from "svelte/internal"
import { pages } from "../../store"
export let path
export let homepage = false
let page: Page
function initPage() {
page = $pages[path]
}
$: {
if (Object.keys($pages).length) {
initPage()
}
}
</script>
<div>
{#if page}
{page.path}
{/if}
</div>
<style lang="less">
</style>

View File

@@ -0,0 +1,6 @@
import { api } from "../../api"
export async function loadPages(): Promise<Page[]> {
let site = await api<Page[]>("page", {})
return site.data
}

View File

@@ -0,0 +1,6 @@
import { api } from "../../api"
export async function loadNavigation(): Promise<Navigation[]> {
let nav = await api<Navigation[]>("navigation", {})
return nav.data
}

15
frontend/src/lib/store.ts Normal file
View File

@@ -0,0 +1,15 @@
import { writable } from "svelte/store"
const initLoc = {
path: (typeof window !== "undefined" && window.location?.pathname) || "/",
search: (typeof window !== "undefined" && window.location?.search) || "",
hash: (typeof window !== "undefined" && window.location?.hash) || "",
push: false,
pop: false,
categoryPath: "",
}
export const location = writable(initLoc)
export let navigation = writable<Navigation>()
export let pages = writable<Pages>({})
export let serviceNavigation = writable<Navigation>()