migrate website to astro

This commit is contained in:
Juan Carlos Manzanero Domínguez
2024-06-25 10:07:29 -06:00
parent f1b9e3ff61
commit 667038d811
71 changed files with 13571 additions and 0 deletions

23
src/utils/format-date.ts Normal file
View File

@ -0,0 +1,23 @@
const months = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
];
export default function formatDate(date: Date | string) {
const newDate = new Date(date);
const month = months[newDate.getMonth()];
const day = newDate.getDate();
const year = newDate.getFullYear();
return `${month} ${day}, ${year}`;
}

36
src/utils/nav-links.tsx Normal file
View File

@ -0,0 +1,36 @@
type TNavItem = {
label: string;
to: string;
};
export const navItems: TNavItem[] = [
{
label: "Blog",
to: "/blog",
},
{
label: "Portfolio",
to: "/portfolio",
},
{
label: "Microblog",
to: "/microblog",
},
{
label: "Resources",
to: "/resources",
},
// {
// label: "Videos",
// to: "/videos",
// },
{
label: "About",
to: "/about",
},
{
label: "Contact",
to: "/contact",
},
];

84
src/utils/pocketbase.ts Normal file
View File

@ -0,0 +1,84 @@
import PocketBase from "pocketbase";
import type { RecordService } from "pocketbase";
export enum Collections {
Microblogs = "microblogs",
Tags = "tags",
Users = "users",
}
export type IsoDateString = string;
export type RecordIdString = string;
export type HTMLString = string;
export type BaseSystemFields<T = never> = {
id: RecordIdString;
created: IsoDateString;
updated: IsoDateString;
collectionId: string;
collectionName: Collections;
expand?: T;
};
export type AuthSystemFields<T = never> = {
email: string;
emailVisibility: boolean;
username: string;
verified: boolean;
} & BaseSystemFields<T>;
export type MicroblogsRecord = {
content?: string;
published: IsoDateString;
tags?: RecordIdString[];
};
export type TagsRecord = {
name?: string;
};
export type UsersRecord = {
avatar?: string;
name?: string;
};
export type MicroblogsResponse<Texpand = unknown> = Required<MicroblogsRecord> &
BaseSystemFields<Texpand>;
export type TagsResponse<Texpand = unknown> = Required<TagsRecord> &
BaseSystemFields<Texpand>;
export type UsersResponse<Texpand = unknown> = Required<UsersRecord> &
AuthSystemFields<Texpand>;
export type CollectionRecords = {
microblogs: MicroblogsRecord;
tags: TagsRecord;
users: UsersRecord;
};
export type CollectionResponses = {
microblogs: MicroblogsResponse;
tags: TagsResponse;
users: UsersResponse;
};
export type TypedPocketBase = PocketBase & {
collection(idOrName: "microblogs"): RecordService<MicroblogsResponse>;
collection(idOrName: "tags"): RecordService<TagsResponse>;
collection(idOrName: "users"): RecordService<UsersResponse>;
};
export function createServerClient(url: string) {
if (!url) {
throw new Error("Pocketbase API url not defined !");
}
if (typeof window !== "undefined") {
throw new Error(
"This method is only supposed to call from the Server environment",
);
}
const client = new PocketBase(url) as TypedPocketBase;
return client;
}