app structure, url redirects

This commit is contained in:
2026-10-06 11:04:09 -04:00
parent bb14cfa5a5
commit 0d647f0529
5 changed files with 70 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
## Status ## Status
### Last Completed ### Last Completed
Started building out the app structure and putting in placeholders for unique rsvp token pages Continued working on the app structure, more specifically started playing around with redirects and created an example registry to see how that would work.
### Next Up ### Next Up
Continue to build on app structure Continue to build on app structure
@@ -36,4 +36,5 @@ For guests that are given a +1, there will be a placeholder name added as a Gues
The `(app)` directory will be for all pages that need to have authentication. These will be the pages that the couple or planner will have access to. Publically facing pages will be in the `(public)` directory (things like the landing page and login page). This will also allow for a "wedding website" option that is publically accessible. The `(app)` directory will be for all pages that need to have authentication. These will be the pages that the couple or planner will have access to. Publically facing pages will be in the `(public)` directory (things like the landing page and login page). This will also allow for a "wedding website" option that is publically accessible.
## Open Questions ## Open Questions
I would like to have a general `AllowList` for the urls in the registry but give users the option to add more to the AllowList if they would like.

22
src/lib/server/data.ts Normal file
View File

@@ -0,0 +1,22 @@
export const RegistryItems = [
{
id: 1,
name: "Item One",
url: "https://www.amazon.com/dp/B071VG5N9D?lv=shuf&social_share=cm_sw_r_cp_ud_dp_HNQ1V69T73P68F2Z4WZK&channelId=751&plpRedirect=mhFallback&th=1",
event: "wedding"
},
{
id: 2,
name: "Another Item",
url: "https://www.target.com",
event: "wedding"
},
];
export const AllowList = [
"https://amazon.com/",
"https://www.amazon.com/",
"https://a.co/",
"https://target.com/",
"https://www.target.com/"
]

View File

@@ -0,0 +1,10 @@
import { RegistryItems } from '#lib/server/data.ts';
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = ({ params }) => {
const items = RegistryItems
.filter((i) => i.event === params.event)
.map(({ id, name }) => ({ id, name }));
return { event: params.event, items };
}

View File

@@ -0,0 +1,16 @@
<script lang="ts">
import type { PageData } from "./$types";
let { data }: { data: PageData } = $props();
</script>
<h1 class="text-3xl font-bold">Registry</h1>
<h2 class="text-lg">Items</h2>
<ul>
{#each data.items as item (item.id)}
<li>
<a href="/{data.event}/registry/{item.id}" target="_blank" class="underline text-blue-500">{item.name}</a>
</li>
{/each}
</ul>

View File

@@ -0,0 +1,19 @@
import { AllowList, RegistryItems } from "#lib/server/data.js";
import { error, redirect } from "@sveltejs/kit";
import type { RequestHandler } from './$types';
export const GET: RequestHandler = ({ params }) => {
const item = RegistryItems.find((i) => String(i.id) === params.item);
if (!item) {
error(404, "Registry Item not found");
};
const protocol = new URL(item.url).protocol;
if (protocol !== 'https:' && protocol !== 'http:') {
error(404, "Invalid Link");
};
redirect(302, item.url, { external: AllowList });
};