feat: add share button

This commit is contained in:
Sonny
2024-11-09 17:34:39 +01:00
committed by Sonny
parent 9250e5f0b4
commit 276abc4009
5 changed files with 61 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
import { Collection, Link } from '~/types/app';
import { Collection, CollectionWithLinks, Link } from '~/types/app';
export const appendCollectionId = (
url: string,
@@ -26,3 +26,11 @@ export function isValidHttpUrl(urlParam: string) {
return url.protocol === 'http:' || url.protocol === 'https:';
}
export const generateShareUrl = (
collection: Collection | CollectionWithLinks
) => {
const pathname = `/shared/${collection.id}`;
if (typeof window === 'undefined') return pathname;
return `${window.location.origin}${pathname}`;
};