From 740e8b5a75b310755311978c468d9aeef11a3583 Mon Sep 17 00:00:00 2001 From: William Diakite Date: Mon, 16 Oct 2023 14:52:38 -0400 Subject: [PATCH] try replace member [slug] with [name=name] --- src/lib/components/Nav.svelte | 4 +++- src/params/name.ts | 13 +++++++++++++ .../{[slug] => [name=name]}/+page.server.ts | 2 +- .../{[slug] => [name=name]}/+page@.svelte | 0 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 src/params/name.ts rename src/routes/[about=about]/[members=members]/{[slug] => [name=name]}/+page.server.ts (94%) rename src/routes/[about=about]/[members=members]/{[slug] => [name=name]}/+page@.svelte (100%) diff --git a/src/lib/components/Nav.svelte b/src/lib/components/Nav.svelte index 27da77b..a591036 100644 --- a/src/lib/components/Nav.svelte +++ b/src/lib/components/Nav.svelte @@ -16,7 +16,9 @@ const getUrl = (name: string) => { if ($page.route.id?.includes('news') || $page.route.id?.includes('projects')) return `${$rt(`route.${name}`)}`; - else return `${$rt(`route.${name}`)}${$page.params.slug ? '/' + $page.params.slug : ''}`; + else if ($page.route.id?.includes('memb')) { + return `${$rt(`route.${name}`)}/${$page.params.name}`; + } else return `${$rt(`route.${name}`)}${$page.params.slug ? '/' + $page.params.slug : ''}`; }; if (route.includes('home')) url = `${$rt('route.home')}`; diff --git a/src/params/name.ts b/src/params/name.ts new file mode 100644 index 0000000..98dc31d --- /dev/null +++ b/src/params/name.ts @@ -0,0 +1,13 @@ +import type { ParamMatcher } from '@sveltejs/kit'; + +export const match = ((param) => { + return param === 'AliceTruc' || + param === 'emchateau' || + param === 'gdJESS' || + param === 'ktanton' || + param === 'LeaMaronet' || + param === 'lenamk' || + param === 'talithamotter' || + param === 'williamdiakite' || + param === 'ZoeRenaudie' +}) satisfies ParamMatcher \ No newline at end of file diff --git a/src/routes/[about=about]/[members=members]/[slug]/+page.server.ts b/src/routes/[about=about]/[members=members]/[name=name]/+page.server.ts similarity index 94% rename from src/routes/[about=about]/[members=members]/[slug]/+page.server.ts rename to src/routes/[about=about]/[members=members]/[name=name]/+page.server.ts index 810bb1c..71cbd35 100644 --- a/src/routes/[about=about]/[members=members]/[slug]/+page.server.ts +++ b/src/routes/[about=about]/[members=members]/[name=name]/+page.server.ts @@ -2,7 +2,7 @@ import { fetchData } from '$lib/helpers/data.js' export const load = async ({ params }) => { const members = await fetchData('team') - const member = members.filter(member => member.meta.slug === params.slug) + const member = members.filter(member => member.meta.slug === params.name) return { member } diff --git a/src/routes/[about=about]/[members=members]/[slug]/+page@.svelte b/src/routes/[about=about]/[members=members]/[name=name]/+page@.svelte similarity index 100% rename from src/routes/[about=about]/[members=members]/[slug]/+page@.svelte rename to src/routes/[about=about]/[members=members]/[name=name]/+page@.svelte