feat(post page): add view specific buttons

This commit is contained in:
plebeius.eth
2024-04-03 22:52:27 +02:00
parent b5fec98f9d
commit f5fefd51cf
6 changed files with 101 additions and 28 deletions
+11
View File
@@ -1,3 +1,14 @@
export type ParamsType = {
commentCid?: string;
subplebbitAddress?: string;
};
export const isHomeView = (pathname: string): boolean => {
return pathname === '/';
};
export const isPostPageView = (pathname: string, params: ParamsType): boolean => {
// some subs might use emojis in their address, so we need to decode the pathname
const decodedPathname = decodeURIComponent(pathname);
return params.subplebbitAddress && params.commentCid ? decodedPathname.startsWith(`/p/${params.subplebbitAddress}/c/${params.commentCid}`) : false;
};