app router

This commit is contained in:
skidoodle 2024-10-29 08:48:57 +01:00
commit 156764768d
27 changed files with 10813 additions and 0 deletions

19
src/app/utils/index.ts Normal file
View file

@ -0,0 +1,19 @@
export default function age() {
const BIRTHDATE = process.env.NEXT_PUBLIC_BIRTHDATE;
if (!BIRTHDATE) {
console.warn("Missing environment variable: BIRTHDATE");
return 0;
}
return Math.floor(
(new Date().getTime() - new Date(BIRTHDATE).getTime()) / 3.15576e10,
);
}
export const truncate = (str: string, n: number): string => {
if (str.length > n) {
const truncated = str.slice(0, n - 3).trimEnd();
return `${truncated}...`;
}
return str.trim();
};