2024-08-03 18:07:27 +02:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { enhance } from "$app/forms";
|
|
|
|
|
import WebsiteEditor from "$lib/components/WebsiteEditor.svelte";
|
2024-08-05 19:33:35 +02:00
|
|
|
import SuccessOrError from "$lib/components/SuccessOrError.svelte";
|
2024-08-05 14:38:44 +02:00
|
|
|
import type { ActionData, PageServerData } from "./$types";
|
2024-09-07 14:28:23 +02:00
|
|
|
import LoadingSpinner from "$lib/components/LoadingSpinner.svelte";
|
2024-09-20 15:56:07 +02:00
|
|
|
import Modal from "$lib/components/Modal.svelte";
|
2024-09-27 16:59:29 +02:00
|
|
|
import { enhanceForm } from "$lib/utils";
|
|
|
|
|
import { sending } from "$lib/runes.svelte";
|
|
|
|
|
import { previewContent } from "$lib/runes.svelte";
|
2024-08-03 18:07:27 +02:00
|
|
|
|
2024-08-20 19:17:05 +02:00
|
|
|
const { data, form }: { data: PageServerData; form: ActionData } = $props();
|
2024-08-30 15:48:15 +02:00
|
|
|
|
2024-09-27 16:59:29 +02:00
|
|
|
previewContent.value = data.websitePreviewUrl;
|
2024-08-03 18:07:27 +02:00
|
|
|
</script>
|
|
|
|
|
|
2024-08-05 19:33:35 +02:00
|
|
|
<SuccessOrError success={form?.success} message={form?.message} />
|
|
|
|
|
|
2024-09-27 16:59:29 +02:00
|
|
|
{#if sending.value}
|
2024-09-07 14:28:23 +02:00
|
|
|
<LoadingSpinner />
|
|
|
|
|
{/if}
|
|
|
|
|
|
2024-08-03 18:07:27 +02:00
|
|
|
<WebsiteEditor
|
2024-09-10 17:29:57 +02:00
|
|
|
id={data.websiteOverview.id}
|
|
|
|
|
contentType={data.websiteOverview.content_type}
|
|
|
|
|
title={data.websiteOverview.title}
|
2024-08-03 18:07:27 +02:00
|
|
|
fullPreview={true}
|
|
|
|
|
>
|
2024-08-24 21:43:15 +02:00
|
|
|
<section id="publish-website">
|
|
|
|
|
<h2>
|
|
|
|
|
<a href="#publish-website">Publish website</a>
|
|
|
|
|
</h2>
|
2024-08-03 18:07:27 +02:00
|
|
|
<p>
|
|
|
|
|
The preview area on this page allows you to see exactly how your website will look when it is
|
|
|
|
|
is published. If you are happy with the results, click the button below and your website will
|
|
|
|
|
be published on the Internet.
|
|
|
|
|
</p>
|
2024-09-27 16:59:29 +02:00
|
|
|
<form method="POST" action="?/publishWebsite" use:enhance={enhanceForm()}>
|
2024-08-03 18:07:27 +02:00
|
|
|
<button type="submit">Publish</button>
|
|
|
|
|
</form>
|
|
|
|
|
</section>
|
2024-09-20 15:56:07 +02:00
|
|
|
|
|
|
|
|
{#if data.websiteOverview.is_published}
|
|
|
|
|
<section id="publication-status">
|
|
|
|
|
<h2>
|
|
|
|
|
<a href="#publication-status">Publication status</a>
|
|
|
|
|
</h2>
|
|
|
|
|
<p>
|
|
|
|
|
Your website is published at:
|
|
|
|
|
<br />
|
|
|
|
|
<a href={data.websiteProdUrl}>{data.websiteProdUrl}</a>
|
|
|
|
|
</p>
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section id="custom-domain-prefix">
|
|
|
|
|
<h2>
|
|
|
|
|
<a href="#custom-domain-prefix">Custom domain prefix</a>
|
|
|
|
|
</h2>
|
|
|
|
|
<form
|
|
|
|
|
method="POST"
|
|
|
|
|
action="?/createUpdateCustomDomainPrefix"
|
2024-09-27 16:59:29 +02:00
|
|
|
use:enhance={enhanceForm({ reset: false })}
|
2024-09-20 15:56:07 +02:00
|
|
|
>
|
|
|
|
|
<label>
|
|
|
|
|
Prefix:
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
name="domain-prefix"
|
|
|
|
|
value={data.websiteOverview.domain_prefix?.prefix ?? ""}
|
|
|
|
|
placeholder="my-blog"
|
|
|
|
|
minlength="3"
|
|
|
|
|
maxlength="16"
|
|
|
|
|
pattern="^[a-z]+(-[a-z]+)*$"
|
|
|
|
|
required
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
<button type="submit">Submit</button>
|
|
|
|
|
</form>
|
|
|
|
|
{#if data.websiteOverview.domain_prefix?.prefix}
|
|
|
|
|
<Modal id="delete-domain-prefix" text="Delete">
|
|
|
|
|
<form
|
|
|
|
|
action="?/deleteCustomDomainPrefix"
|
|
|
|
|
method="post"
|
2024-09-27 16:59:29 +02:00
|
|
|
use:enhance={enhanceForm({ closeModal: true })}
|
2024-09-20 15:56:07 +02:00
|
|
|
>
|
|
|
|
|
<h3>Delete domain prefix</h3>
|
|
|
|
|
<p>
|
|
|
|
|
<strong>Caution!</strong>
|
|
|
|
|
This action will remove the domain prefix and reset it to its initial value.
|
|
|
|
|
</p>
|
|
|
|
|
<button type="submit">Delete domain prefix</button>
|
|
|
|
|
</form>
|
|
|
|
|
</Modal>
|
|
|
|
|
{/if}
|
|
|
|
|
</section>
|
|
|
|
|
{/if}
|
2024-08-03 18:07:27 +02:00
|
|
|
</WebsiteEditor>
|