Add custom domain prefixes and option to disable user registration

This commit is contained in:
thiloho
2024-09-20 15:56:07 +02:00
parent 4300988463
commit 86ab737429
12 changed files with 368 additions and 57 deletions

View File

@@ -4,6 +4,7 @@
import SuccessOrError from "$lib/components/SuccessOrError.svelte";
import type { ActionData, PageServerData } from "./$types";
import LoadingSpinner from "$lib/components/LoadingSpinner.svelte";
import Modal from "$lib/components/Modal.svelte";
const { data, form }: { data: PageServerData; form: ActionData } = $props();
@@ -45,18 +46,73 @@
>
<button type="submit">Publish</button>
</form>
{#if data.websiteOverview.is_published}
<section id="publication-status">
<h3>
<a href="#publication-status">Publication status</a>
</h3>
<p>
Your website is published at:
<br />
<a href={data.websiteProdUrl}>{data.websiteProdUrl}</a>
</p>
</section>
{/if}
</section>
{#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"
use:enhance={() => {
sending = true;
return async ({ update }) => {
await update();
sending = false;
};
}}
>
<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"
use:enhance={() => {
sending = true;
return async ({ update }) => {
await update();
window.location.hash = "!";
sending = false;
};
}}
>
<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}
</WebsiteEditor>