2023-04-19 22:44:06 +02:00
|
|
|
import {
|
2023-05-29 16:22:34 +02:00
|
|
|
DateFormat,
|
|
|
|
PageHeader,
|
|
|
|
Section,
|
|
|
|
Container,
|
2023-04-19 22:44:06 +02:00
|
|
|
} from "./components/index.js";
|
|
|
|
|
|
|
|
const BlogPreview = ({ widgetFor, entry, fields, collection }) => {
|
2023-05-29 16:22:34 +02:00
|
|
|
const imageField = useMemo(() => {
|
|
|
|
return fields.find((field) => field.name === "image");
|
|
|
|
}, [fields]);
|
2023-04-19 22:44:06 +02:00
|
|
|
|
2023-05-29 16:22:34 +02:00
|
|
|
const imageUrl = useMediaAsset(
|
|
|
|
entry.data.image,
|
|
|
|
collection,
|
|
|
|
imageField,
|
|
|
|
entry
|
|
|
|
);
|
|
|
|
return [
|
|
|
|
PageHeader(entry),
|
|
|
|
Section(
|
2023-07-31 20:54:52 +02:00
|
|
|
Container([
|
|
|
|
h("img", { className: "img-fluid w-100 mb-4", src: imageUrl }),
|
|
|
|
h(
|
|
|
|
"div",
|
|
|
|
{ className: "d-flex flex-wrap gap-2 justify-content-between" },
|
2023-05-29 16:22:34 +02:00
|
|
|
h(
|
|
|
|
"div",
|
2023-07-31 20:54:52 +02:00
|
|
|
{ className: "text-body-secondary" },
|
|
|
|
h("span", { className: "fw-bold me-1" }, "Geschrieben von:"),
|
|
|
|
widgetFor("author")
|
2023-05-29 16:22:34 +02:00
|
|
|
),
|
|
|
|
h(
|
|
|
|
"div",
|
2023-07-31 20:54:52 +02:00
|
|
|
{ className: "text-body-secondary" },
|
|
|
|
h("span", { className: "fw-bold me-1" }, "Datum:"),
|
|
|
|
entry.data.date
|
|
|
|
? DateFormat({
|
|
|
|
date: entry.data.date,
|
|
|
|
format: {
|
|
|
|
day: "numeric",
|
|
|
|
month: "short",
|
|
|
|
year: "numeric",
|
|
|
|
},
|
|
|
|
})
|
|
|
|
: ""
|
2023-05-29 16:22:34 +02:00
|
|
|
),
|
|
|
|
h(
|
|
|
|
"div",
|
2023-07-31 20:54:52 +02:00
|
|
|
{ className: "text-body-secondary" },
|
|
|
|
h("span", { className: "fw-bold me-1" }, "Kategorien:"),
|
|
|
|
entry.data.categories
|
|
|
|
? entry.data.categories.map(
|
|
|
|
(category, index) => (index != 0 ? ", " : "") + category
|
|
|
|
)
|
|
|
|
: ""
|
|
|
|
)
|
|
|
|
),
|
|
|
|
h("div", { className: "border-bottom my-4" }),
|
|
|
|
h(
|
|
|
|
"div",
|
|
|
|
{
|
|
|
|
className: "content text-justify mb-4",
|
|
|
|
},
|
|
|
|
widgetFor("body")
|
|
|
|
),
|
|
|
|
])
|
2023-05-29 16:22:34 +02:00
|
|
|
),
|
|
|
|
];
|
2023-04-19 22:44:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default BlogPreview;
|