--- import AppLayout from "components/AppLayout/AppLayout.astro"; import AppLayoutTitle from "components/AppLayout/components/AppLayoutTitle.astro"; import Attributes from "components/Attributes.astro"; import Credits from "components/Credits.astro"; import DownloadButton from "components/DownloadButton.astro"; import RichText from "components/RichText/RichText.astro"; import { getI18n } from "src/i18n/i18n"; import { payload } from "src/services"; import { formatInlineTitle, formatRichTextToString } from "src/utils/format"; import { fetchOr404 } from "src/utils/responses"; import { getFileIcon } from "src/utils/attributes"; import { Icon } from "astro-icon/components"; import { sizesToSrcset } from "src/utils/img"; const id = Astro.params.id!; const response = await fetchOr404(() => payload.getFileByID(id)); if (response instanceof Response) { return response; } const { translations, attributes, filename, url, credits, mimeType, filesize, updatedAt, createdAt, thumbnail, backlinks, } = response.data; const { getLocalizedMatch, t, formatFilesize, formatDate } = await getI18n( Astro.locals.currentLocale ); const { pretitle, title, subtitle, description, language } = translations.length > 0 ? getLocalizedMatch(translations) : { pretitle: undefined, title: filename, subtitle: undefined, description: undefined, language: undefined, }; const metaAttributes = [ ...(filename && title !== filename && thumbnail ? [ { title: t("global.media.attributes.filename"), icon: getFileIcon(mimeType), values: [{ name: filename }], withBorder: false, }, ] : []), { title: t("global.media.attributes.filesize"), icon: "material-symbols:hard-drive", values: [{ name: formatFilesize(filesize) }], withBorder: false, }, { title: t("global.media.attributes.createdAt"), icon: "material-symbols:calendar-add-on", values: [{ name: formatDate(new Date(createdAt)) }], withBorder: false, }, { title: t("global.media.attributes.updatedAt"), icon: "material-symbols:edit-calendar", values: [{ name: formatDate(new Date(updatedAt)) }], withBorder: false, }, ]; const smallTitle = title === filename; --- {/* ------------------------------------------- HTML ------------------------------------------- */}
{ thumbnail ? ( ) : (

{filename}

) }
{ smallTitle ? (

{title}

) : ( ) } {description && } {attributes.length > 0 && } {credits.length > 0 && } {metaAttributes.length > 0 && } {filename && }
{/* ------------------------------------------- CSS -------------------------------------------- */}