mirror of
https://github.com/khairul169/code-share.git
synced 2026-10-24 11:53:58 +07:00
feat: add project schema
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { type ClassValue, clsx } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
import { BASE_URL } from "./consts";
|
||||
import type { ProjectSchema } from "~/server/db/schema/project";
|
||||
import type { FileSchema } from "~/server/db/schema/file";
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
@@ -13,3 +15,13 @@ export function getFileExt(filename: string) {
|
||||
export function getUrl(...path: string[]) {
|
||||
return BASE_URL + ("/" + path.join("/")).replace(/\/\/+/g, "/");
|
||||
}
|
||||
|
||||
export function getPreviewUrl(
|
||||
project: Pick<ProjectSchema, "slug">,
|
||||
file: string | Pick<FileSchema, "path">
|
||||
) {
|
||||
return getUrl(
|
||||
`api/preview/${project.slug}`,
|
||||
typeof file === "string" ? file : file.path
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user