|
| 1 | +--- |
| 2 | +import type { CollectionEntry } from 'astro:content'; |
| 3 | +import { Image } from "astro:assets"; |
| 4 | +import { URLify } from '../scripts/urlify.js'; |
| 5 | +import { humanizeISO8601Duration } from '../scripts/duration.js'; |
| 6 | +import { truncateDescription } from '../scripts/text.js'; |
| 7 | +import TagBadge from '../components/TagBadge.astro'; |
| 8 | +
|
| 9 | +export interface Props { |
| 10 | + movie: CollectionEntry<'awesome-software-engineering-movies'>; |
| 11 | +} |
| 12 | +
|
| 13 | +const { movie } = Astro.props; |
| 14 | +
|
| 15 | +let tags = []; |
| 16 | +if (movie.data.tags) { |
| 17 | + tags = movie.data.tags.map((element) => URLify(element)); |
| 18 | +} |
| 19 | +
|
| 20 | +// Generate id based on the slug (slug is upstream-controlled and stable) |
| 21 | +const nameId = URLify(movie.data.slug); |
| 22 | +
|
| 23 | +const duration = humanizeISO8601Duration(movie.data.duration); |
| 24 | +const publishedDate = new Date(movie.data.publishedAt).toLocaleDateString('de-DE', { year: 'numeric', month: 'long', day: 'numeric' }); |
| 25 | +const description = truncateDescription(movie.data.description); |
| 26 | +--- |
| 27 | + |
| 28 | +<section |
| 29 | + id={nameId.url} |
| 30 | + class="movie py-8 md:py-12 bg-white overflow-hidden" |
| 31 | + style="background-image: url('/images/elements/pattern-white.svg'); background-position: center;" |
| 32 | +> |
| 33 | + <div class="container px-4 mx-auto"> |
| 34 | + <div class="flex flex-wrap lg:items-center -mx-4"> |
| 35 | + <div class="w-full md:w-8/12 px-4 mb-16 md:mb-0"> |
| 36 | + { |
| 37 | + tags.map((element) => ( |
| 38 | + <TagBadge name={element.name} url={`/filme-fuer-softwareentwickler/${element.url}-filme/`} /> |
| 39 | + )) |
| 40 | + } |
| 41 | + |
| 42 | + <h2 class="mb-8 text-4xl md:text-5xl leading-tight text-coolGray-900 font-bold tracking-tight"> |
| 43 | + <a href={movie.data.link} class="hover:underline hover:text-yellow-500" title={`${movie.data.name} auf YouTube ansehen`} rel="noopener"> |
| 44 | + {movie.data.name} |
| 45 | + </a> |
| 46 | + </h2> |
| 47 | + <p class="mb-6 text-lg md:text-xl text-coolGray-500 font-medium"> |
| 48 | + {description} |
| 49 | + </p> |
| 50 | + <ul class="mb-4 text-lg md:text-xl text-coolGray-500 font-medium"> |
| 51 | + <li class="pb-2">Dauer: {duration}</li> |
| 52 | + <li class="pb-2">Veröffentlicht: {publishedDate}</li> |
| 53 | + <li class="pb-2 space-x-2">Sprache: |
| 54 | + {movie.data.language.map((lang) => ( |
| 55 | + <span class="inline-block px-2 py-0.5 text-sm bg-coolGray-100 rounded">{lang.toUpperCase()}</span> |
| 56 | + ))} |
| 57 | + </li> |
| 58 | + </ul> |
| 59 | + |
| 60 | + <div class="flex flex-wrap"> |
| 61 | + <div class="mb-4 mt-4 mr-4"> |
| 62 | + <a class="flex items-center" href={movie.data.link} title={`${movie.data.name} auf YouTube ansehen`} rel="noopener"> |
| 63 | + <img class="w-8" src="/images/brands/youtube.svg" alt={`${movie.data.name} auf YouTube`} title={`${movie.data.name} auf YouTube`} /> |
| 64 | + <span class="text-coolGray-500 text-lg m-2">YouTube</span> |
| 65 | + </a> |
| 66 | + </div> |
| 67 | + </div> |
| 68 | + </div> |
| 69 | + <div class="w-full md:w-4/12 px-4"> |
| 70 | + <div class="relative mx-auto md:mr-0 max-w-max"> |
| 71 | + <a href={movie.data.link} title={`${movie.data.name} auf YouTube ansehen`} rel="noopener"> |
| 72 | + <Image class="rounded-2xl" src={movie.data.image} alt={`Film ${movie.data.name}`} title={`Film ${movie.data.name}`} loading="lazy" decoding="async" format="webp" quality={80} /> |
| 73 | + </a> |
| 74 | + </div> |
| 75 | + </div> |
| 76 | + </div> |
| 77 | + </div> |
| 78 | +</section> |
0 commit comments