diff --git a/lib/main.js b/lib/main.js index 67ae144..3a543e1 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,8 +26,6 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -import "./scss/style.scss"; - const INSTANCE_LIST_URL = "https://api.joinmastodon.org/servers"; const LOCAL_STORAGE_KEY = "recentInstances"; const RECENT_INSTANCES_SIZE = 5; diff --git a/src/pages/api/share.ts b/src/pages/api/share.ts new file mode 100644 index 0000000..5a1cbfc --- /dev/null +++ b/src/pages/api/share.ts @@ -0,0 +1,16 @@ +import { APIRoute } from "astro"; + +export const post: APIRoute = async ({ redirect, request }) => { + const formData = await request.formData(); + + const text = (formData.get("text") as string) || ""; + const instanceURL = + (formData.get("instance") as string) || "https://mastodon.social"; + + const publishUrl = new URL("/share", instanceURL); + publishUrl.search = new URLSearchParams({ + text, + }).toString(); + + return redirect(publishUrl.toString(), 303); +}; diff --git a/index.html b/src/pages/index.astro similarity index 96% rename from index.html rename to src/pages/index.astro index 7f79490..b608e4a 100644 --- a/index.html +++ b/src/pages/index.astro @@ -1,5 +1,9 @@ +--- +import "../styles/main.scss"; +--- + + +