From 5211188dbc1529449c95d468875c03507d255443 Mon Sep 17 00:00:00 2001 From: Omer Sabic Date: Sat, 24 Aug 2024 13:24:12 +0200 Subject: [PATCH] added contact page --- src/routes/+layout.svelte | 5 ++- src/routes/contact/+page.server.js | 47 ++++++++++++++++++++++++ src/routes/contact/+page.svelte | 28 ++++++++++++++ static/SeorGrBp5preyO7sH0fCsTyaJLM.webp | Bin 0 -> 1174 bytes static/favicon.ico | Bin 0 -> 3774 bytes static/favicon.png | Bin 1571 -> 0 bytes 6 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 src/routes/contact/+page.server.js create mode 100644 src/routes/contact/+page.svelte create mode 100644 static/SeorGrBp5preyO7sH0fCsTyaJLM.webp create mode 100644 static/favicon.ico delete mode 100644 static/favicon.png diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index fefb43c..a838e6c 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -15,10 +15,13 @@ >
{data.blog.site.name} -
+
{#if data.blog.site.use_about_page} About {/if} + {#if data.blog.site.use_contact_page} + Contact + {/if}
diff --git a/src/routes/contact/+page.server.js b/src/routes/contact/+page.server.js new file mode 100644 index 0000000..b0b34ad --- /dev/null +++ b/src/routes/contact/+page.server.js @@ -0,0 +1,47 @@ +import { redirect } from "@sveltejs/kit"; +import { get } from 'svelte/store'; +import { site_id } from '../store'; +import { env } from '$lib'; + +/** @type {import("@sveltejs/kit").Actions} */ +export const actions = { + contact: async (event) => { + const data = await event.request.formData(); + + const subject = data.get("subject"); + const email = data.get("email"); + const message = data.get("message"); + + if (!subject || !email || !message) { + return { + success: false, + message: "missing data" + } + } + + if (!email.toString().includes("@")) { + return { + success: false, + message: "invalid email" + } + } + + let res = await fetch(env.api_url + "/blog/contact", { + method: "POST", + headers: { + "content-type": "application/json" + }, + body: JSON.stringify({ + subject, + email, + content: message, + blog_id: get(site_id) + }) + }); + console.log(await res.text()); + + return { + success: true + } + }, +} \ No newline at end of file diff --git a/src/routes/contact/+page.svelte b/src/routes/contact/+page.svelte new file mode 100644 index 0000000..22684ac --- /dev/null +++ b/src/routes/contact/+page.svelte @@ -0,0 +1,28 @@ +
+
+ + +