|
|
@ -1,8 +1,14 @@ |
|
|
|
import { withTrailingSlash, withLeadingSlash, joinURL } from "ufo" |
|
|
|
import { withTrailingSlash, withLeadingSlash, joinURL } from "ufo" |
|
|
|
import { useRuntimeConfig } from "#imports" |
|
|
|
import { useRuntimeConfig } from "#imports" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns if environment is in development mode |
|
|
|
|
|
|
|
*/ |
|
|
|
export const isDev = process.env.NODE_ENV === "development"; |
|
|
|
export const isDev = process.env.NODE_ENV === "development"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Gets URL path, taking into acount the baseURL |
|
|
|
|
|
|
|
*/ |
|
|
|
export const getPublicPath = function (path: string): string { |
|
|
|
export const getPublicPath = function (path: string): string { |
|
|
|
if (path?.startsWith("/") && !path.startsWith("//")) { |
|
|
|
if (path?.startsWith("/") && !path.startsWith("//")) { |
|
|
|
const _base = withLeadingSlash(withTrailingSlash(useRuntimeConfig().app.baseURL)); |
|
|
|
const _base = withLeadingSlash(withTrailingSlash(useRuntimeConfig().app.baseURL)); |
|
|
@ -10,7 +16,23 @@ export const getPublicPath = function (path: string): string { |
|
|
|
return joinURL(_base, path); |
|
|
|
return joinURL(_base, path); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return path; |
|
|
|
return path; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// datetime format
|
|
|
|
/** |
|
|
|
|
|
|
|
* Return date string in format "Feb 10, 2025" |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
export const prettyDate = function (date: string | Date): string { |
|
|
|
|
|
|
|
if (typeof date === "string") { |
|
|
|
|
|
|
|
date = new Date(date); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const formatted = new Intl.DateTimeFormat("en-US", { |
|
|
|
|
|
|
|
month: "short", |
|
|
|
|
|
|
|
day: "numeric", |
|
|
|
|
|
|
|
year: "numeric" |
|
|
|
|
|
|
|
}).format(date); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return formatted; |
|
|
|
|
|
|
|
} |
|
|
|