view file & image

This commit is contained in:
2025-06-22 07:00:21 +02:00
parent 45e0989c5d
commit 0dcc1323bd
3 changed files with 73 additions and 8 deletions

View File

@@ -8,7 +8,7 @@
<!-- Logo/Brand --> <!-- Logo/Brand -->
<div class="flex items-center"> <div class="flex items-center">
<a href="/" class="text-xl font-bold text-gray-800 hover:text-gray-600 transition-colors"> <a href="/" class="text-xl font-bold text-gray-800 hover:text-gray-600 transition-colors">
Pole Sport Pole Book
</a> </a>
</div> </div>

View File

@@ -1,5 +1,5 @@
--- ---
import MardownContent from '../../components/MardownContent.astro'; import ElementView from '../../views/ElementView.astro';
import Layout from '../../layouts/Layout.astro'; import Layout from '../../layouts/Layout.astro';
import fetchApi from '../../lib/strapi'; import fetchApi from '../../lib/strapi';
@@ -25,6 +25,5 @@ try {
--- ---
<Layout title={poleElement.name} description={poleElement.description}> <Layout title={poleElement.name} description={poleElement.description}>
<h1>{poleElement.name}</h1> <ElementView entry={{ data: poleElement }} />
{poleElement.description && <MardownContent content={poleElement.description} />}
</Layout> </Layout>

View File

@@ -1,23 +1,43 @@
--- ---
import MardownContent from '../components/MardownContent.astro'; import MardownContent from '../components/MardownContent.astro';
import { getStrapiMedia } from '../lib/strapi';
import { getStrapiBaseUrl } from '../config/strapi';
interface Props { interface Props {
entry: { entry: {
data: { data: {
title: string; name: string;
description: string; description: string;
mainImage: {
url: string;
alternativeText: string;
};
}; };
}; };
} }
const { entry } = Astro.props; const { entry } = Astro.props;
const BASE_URL = getStrapiBaseUrl();
--- ---
<div class="element-view"> <div class="element-view">
<h1>{entry.data.title}</h1> <div class="element-content">
<div class="element-text">
<h1>{entry.data.name}</h1>
<MardownContent content={entry.data.description} /> <MardownContent content={entry.data.description} />
</div> </div>
{entry.data.mainImage && (
<div class="element-image">
<img
src={getStrapiMedia(entry.data.mainImage.url, BASE_URL)}
alt={entry.data.mainImage.alternativeText}
class="main-image"
/>
</div>
)}
</div>
</div>
<style> <style>
.element-view { .element-view {
max-width: 56rem; max-width: 56rem;
@@ -25,6 +45,20 @@ const { entry } = Astro.props;
margin-right: auto; margin-right: auto;
} }
.element-content {
display: flex;
flex-direction: column;
gap: 2rem;
}
.element-text {
order: 2;
}
.element-image {
order: 1;
}
.element-view h1 { .element-view h1 {
font-size: 2.25rem; font-size: 2.25rem;
font-weight: 700; font-weight: 700;
@@ -33,4 +67,36 @@ const { entry } = Astro.props;
margin-top: 2rem; margin-top: 2rem;
line-height: 1.2; line-height: 1.2;
} }
.main-image {
width: 100%;
height: auto;
border-radius: 0.5rem;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
/* Desktop styles */
@media (min-width: 768px) {
.element-content {
flex-direction: row;
align-items: flex-start;
gap: 3rem;
}
.element-text {
order: 1;
flex: 1;
}
.element-image {
order: 2;
flex-shrink: 0;
width: 300px;
}
.main-image {
width: 300px;
height: auto;
}
}
</style> </style>