-
Notifications
You must be signed in to change notification settings - Fork 0
/
+page.svelte
84 lines (73 loc) · 2.29 KB
/
+page.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<script>
import Footer from '$lib/components/Footer.svelte';
import PlainText from '$lib/components/PlainText.svelte';
import RichText from '$lib/components/RichText.svelte';
import LoginMenu from '$lib/components/LoginMenu.svelte';
import PrimaryButton from '$lib/components/PrimaryButton.svelte';
import { fetchJSON } from '$lib/util';
import { currentUser, isEditing } from '$lib/stores.js';
import WebsiteHeader from '$lib/components/WebsiteHeader.svelte';
export let data;
let showUserMenu = false,
title,
imprint;
// --------------------------------------------------------------------------
// DEFAULT PAGE CONTENT - AJDUST TO YOUR NEEDS
// --------------------------------------------------------------------------
function initOrReset() {
$currentUser = data.currentUser;
title = data.page?.title || 'Imprint';
imprint =
data.page?.imprint ||
[
['Ken Experiences GmbH', 'Mozartstraße 56', '4020 Linz, Austria'].join('<br/>'),
[
'Managing Director: DI Michael Aufreiter',
'Register No: FN 408728x',
'Court: Linz',
'VAT ID: ATU68395257'
].join('<br/>')
]
.map(text => `<p>${text}</p>`)
.join('\n');
}
initOrReset();
function toggleEdit() {
$isEditing = true;
showUserMenu = false;
}
async function savePage() {
if (!$currentUser) return alert('Sorry, you are not authorized.');
try {
fetchJSON('POST', '/api/save-page', {
pageId: 'imprint',
page: {
title,
imprint
}
});
$isEditing = false;
} catch (err) {
console.error(err);
alert('There was an error. Please try again.');
}
}
</script>
<svelte:head>
<title>Imprint</title>
</svelte:head>
<WebsiteHeader bind:showUserMenu on:cancel={initOrReset} on:save={savePage}>
<PrimaryButton on:click={toggleEdit}>Edit page</PrimaryButton>
<LoginMenu />
</WebsiteHeader>
<div class="py-12 sm:py-24">
<div class="max-w-screen-md mx-auto px-6 md:text-xl">
<h1 class="text-4xl md:text-7xl font-bold pb-8">
<PlainText bind:content={title} />
</h1>
<div class="prose md:prose-xl pb-12 sm:pb-24">
<RichText multiLine bind:content={imprint} />
</div>
</div>
</div>
<Footer counter="/imprint" />