gcg-website/static/admin/previews/page-previews/author-preview.js

44 lines
1.2 KiB
JavaScript
Raw Normal View History

import { Container, PageHeader, Section, md5 } from "./components/index.js";
const AuthorPreview = ({ widgetFor, entry, fields, collection }) => {
2023-05-29 16:22:34 +02:00
const imageField = useMemo(
() => fields.find((field) => field.name === "image"),
[fields]
);
2023-05-29 16:22:34 +02:00
const imageUrl = entry.data.image
? useMediaAsset(entry.data.image, collection, imageField, entry)
: entry.data.email
? undefined
: useMediaAsset("/media/people/gcg.webp", collection, imageField, entry);
2023-05-29 16:22:34 +02:00
return [
PageHeader(entry),
Section(
Container([
2023-05-29 16:22:34 +02:00
h(
"div",
{ className: "text-center" },
h("img", {
className: "rounded-circle img-fluid mb-4",
src:
imageUrl ??
"https://www.gravatar.com/avatar/" +
md5(entry.data.email) +
"?s=128&pg&d=identicon",
width: "128px",
height: "128px",
}),
h("h4", { className: "fw-bold" }, entry.data.title),
h("hr"),
widgetFor("body"),
h("hr"),
entry.data.email ? h("i", { className: "mdi mdi-at" }) : null
),
])
2023-05-29 16:22:34 +02:00
),
];
};
export default AuthorPreview;