router matching
Unanswered
American black bear posted this in #help-forum
American black bearOP
I'm having a hard time with TRPC, and how to decode a slug to match one name in my database list. I'm using t3 stack.
6 Replies
American black bearOP
examples around this or issues experiencied would be highly appreciated!
European sprat
T3 stack has a discord. Such a question might be better handled there. In any case, you will need to share a lot more detail if you want someone to help
American black bearOP
thanks, maybe more prisma related issue tho
soo while I'm trying to use ServerSideProps I might better ask this here 🙂
export function getServerSideProps(context: GetServerSidePropsContext<{ params }: Params>) {
const params = context.params?.category;
// const ssr = ssrHelper();
const categorySlug: string = params || "";
function SlugToName(slug: string, fields: string[] = []) {
return slug
.split('-')
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
.join(' ');
}
const post = SlugToName(params.slug, [
'title',
'date',
'slug',
'author',
'content',
'ogImage',
'coverImage',
])
return {
props: {
// trpcState: ssr.dehydrate(),
category,
}
};
}is there a better way to handle this?