generated from gitea_admin/default
Concerts
This commit is contained in:
16
app/utils/dateFormat.js
Normal file
16
app/utils/dateFormat.js
Normal file
@@ -0,0 +1,16 @@
|
||||
export function formatDateLong(iso) {
|
||||
if (!iso) return ""
|
||||
const d = new Date(iso)
|
||||
const date = new Intl.DateTimeFormat("fr-FR", {
|
||||
weekday: "long",
|
||||
day: "numeric",
|
||||
month: "long",
|
||||
year: "numeric",
|
||||
}).format(d)
|
||||
const time = new Intl.DateTimeFormat("fr-FR", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
hour12: false,
|
||||
}).format(d).replace(":", "h")
|
||||
return `${date} — ${time}`
|
||||
}
|
||||
33
app/utils/strapi.js
Normal file
33
app/utils/strapi.js
Normal file
@@ -0,0 +1,33 @@
|
||||
// app/utils/strapi.js
|
||||
|
||||
export function getStrapiBaseUrl(event) {
|
||||
// En server/Nitro, on récupère runtimeConfig via l'event si dispo,
|
||||
// sinon on retombe sur la variable d'env publique.
|
||||
const base =
|
||||
event?.context?.runtimeConfig?.public?.strapiUrl ||
|
||||
process.env.NUXT_PUBLIC_STRAPI_URL
|
||||
|
||||
if (!base) {
|
||||
throw new Error("Missing runtimeConfig.public.strapiUrl (NUXT_PUBLIC_STRAPI_URL)")
|
||||
}
|
||||
|
||||
try {
|
||||
new URL(base)
|
||||
} catch {
|
||||
throw new Error(`Invalid Strapi base URL: ${base}`)
|
||||
}
|
||||
|
||||
return base.replace(/\/$/, "")
|
||||
}
|
||||
|
||||
export async function strapiFetch(event, path, options = {}) {
|
||||
const base = getStrapiBaseUrl(event)
|
||||
const url = `${base}${path.startsWith("/") ? path : `/${path}`}`
|
||||
|
||||
return await $fetch(url, {
|
||||
...options,
|
||||
headers: {
|
||||
...(options.headers || {}),
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user