LargePreview
This commit is contained in:
parent
99f91607d5
commit
640d1e25b3
12 changed files with 159 additions and 34 deletions
BIN
src/assets/blog_img/blog1_title.png
Executable file
BIN
src/assets/blog_img/blog1_title.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 14 MiB |
BIN
src/assets/blog_img/blog2_title.png
Executable file
BIN
src/assets/blog_img/blog2_title.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 4.6 MiB |
BIN
src/assets/blog_img/blog3_title.png
Executable file
BIN
src/assets/blog_img/blog3_title.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 12 MiB |
75
src/components/PostPreviewLarge.astro
Normal file
75
src/components/PostPreviewLarge.astro
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
---
|
||||||
|
import type { Post } from "../types/global";
|
||||||
|
import { findImageByPath } from "../lib/findImage";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
post: Post;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { post, url } = Astro.props;
|
||||||
|
|
||||||
|
const img = findImageByPath(post.image.path);
|
||||||
|
---
|
||||||
|
|
||||||
|
<a href={url} class="no-link-link">
|
||||||
|
<div class="wide-container">
|
||||||
|
<div class="image-col col">
|
||||||
|
<img src={img.src} alt={post.image.alt} />
|
||||||
|
</div>
|
||||||
|
<div class="text-col col">
|
||||||
|
<h2 class="headline">{post.title}</h2>
|
||||||
|
<h7 class="subtitle">{post.subtitle}</h7>
|
||||||
|
<p class="description">{post.description}</p>
|
||||||
|
<div class="bottom-info">
|
||||||
|
<span>Author: {post.author}</span>
|
||||||
|
<span>{post.date}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.wide-container {
|
||||||
|
display: flex;
|
||||||
|
gap: 32px;
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.col {
|
||||||
|
width: 50%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
min-width: 0;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-col {
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: flex-start;
|
||||||
|
margin: 32px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-col {
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-col img {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
object-position: center;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bottom-info {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import { findImageByPath } from "../lib/findImage";
|
||||||
import type { Post } from "../types/global";
|
import type { Post } from "../types/global";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|
@ -7,15 +9,16 @@ interface Props {
|
||||||
}
|
}
|
||||||
|
|
||||||
const { post, url } = Astro.props;
|
const { post, url } = Astro.props;
|
||||||
|
|
||||||
|
const img = findImageByPath(post.image.path)
|
||||||
---
|
---
|
||||||
|
|
||||||
<a href={url}>
|
<a href={url} class="no-link-link">
|
||||||
<div class="frame">
|
<div class="frame">
|
||||||
<img src="" />
|
<img src={img.src} alt={post.image.alt} />
|
||||||
<h3>{post.title}</h3>
|
<h2 class="headline">{post.title}</h2>
|
||||||
<span class="subtitle">{post.subtitle}</span>
|
<h7 class="subtitle">{post.subtitle}</h7>
|
||||||
<br />
|
<p class="description">{post.description}</p>
|
||||||
<br />
|
|
||||||
<div class="bottom-info">
|
<div class="bottom-info">
|
||||||
<span>Author: {post.author}</span>
|
<span>Author: {post.author}</span>
|
||||||
<span>{post.date}</span>
|
<span>{post.date}</span>
|
||||||
|
|
@ -25,37 +28,26 @@ const { post, url } = Astro.props;
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.frame {
|
.frame {
|
||||||
flex: auto 0 0;
|
flex: 220px; auto 0 0;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
display: block;
|
display: flex;
|
||||||
border: 2px solid black;
|
flex-direction: column;
|
||||||
border-radius: 12px;
|
border: 1px solid black;
|
||||||
|
border-radius: 8px;
|
||||||
width: 240px;
|
width: 240px;
|
||||||
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
max-height: 230px;
|
max-height: 220px;
|
||||||
width: 220px;
|
width: 220px;
|
||||||
border-radius: 12px;
|
border-radius: 8px;
|
||||||
aspect-ratio: 1 / 1;
|
aspect-ratio: 1 / 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
.bottom-info {
|
||||||
margin-top: 8px;
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.subtitle {
|
|
||||||
font-weight: lighter;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bottom-info {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
margin-top: auto;
|
||||||
|
|
||||||
a {
|
|
||||||
text-decoration: none;
|
|
||||||
color: black;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
13
src/lib/findImage.ts
Normal file
13
src/lib/findImage.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
const images = import.meta.glob("/src/assets/**/*.{jpg,png}", { eager: true }) as Record<string, { default: string }>;
|
||||||
|
|
||||||
|
export function findImageByPath(path: string, { fallback }: { fallback?: string } = {}): any {
|
||||||
|
if (!path) return fallback ?? null;
|
||||||
|
const key = Object.keys(images).find(
|
||||||
|
p => p.endsWith("/" + path) || p.endsWith(path)
|
||||||
|
);
|
||||||
|
if (!key) {
|
||||||
|
if (fallback) return fallback;
|
||||||
|
throw new Error(`Image not found: ${path}`);
|
||||||
|
}
|
||||||
|
return images[key].default;
|
||||||
|
}
|
||||||
|
|
@ -1,18 +1,28 @@
|
||||||
---
|
---
|
||||||
import Main from "../layouts/Main.astro";
|
import Main from "../layouts/Main.astro";
|
||||||
import PostPreviewSmall from "../components/PostPreviewSmall.astro";
|
import PostPreviewSmall from "../components/PostPreviewSmall.astro";
|
||||||
|
import PostPreviewLarge from "../components/PostPreviewLarge.astro";
|
||||||
|
|
||||||
const allPosts: Array<any> = Object.values(
|
const allPosts: Array<any> = Object.values(
|
||||||
import.meta.glob("./posts/*.md", { eager: true })
|
import.meta.glob("./posts/*.md", { eager: true })
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const mostRecentPost = allPosts.at(allPosts.length - 1);
|
||||||
|
console.log(mostRecentPost)
|
||||||
---
|
---
|
||||||
|
|
||||||
<Main title="Startseite">
|
<Main title="Startseite">
|
||||||
|
<PostPreviewLarge
|
||||||
|
url={mostRecentPost.url}
|
||||||
|
post={mostRecentPost.frontmatter}
|
||||||
|
/>
|
||||||
<div class="post-grid">
|
<div class="post-grid">
|
||||||
{
|
{
|
||||||
allPosts.map((post_file: any) => (
|
allPosts
|
||||||
<PostPreviewSmall url={post_file.url} post={post_file.frontmatter}> </PostPreviewSmall>
|
.slice(0, allPosts.length - 1)
|
||||||
))
|
.map((post_file: any) => (
|
||||||
|
<PostPreviewSmall url={post_file.url} post={post_file.frontmatter} />
|
||||||
|
))
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</Main>
|
</Main>
|
||||||
|
|
@ -21,7 +31,7 @@ const allPosts: Array<any> = Object.values(
|
||||||
.post-grid {
|
.post-grid {
|
||||||
padding: 24px 24px;
|
padding: 24px 24px;
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 16px;
|
gap: 32px;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
---
|
---
|
||||||
title: 'The first post'
|
title: 'The first post'
|
||||||
subtitle: "In the first post we're talking about some nice luxury hotels. Stay tuned!"
|
subtitle: "Luxury Hotels at its best!"
|
||||||
|
description: "In the first post we're talking about some nice luxury hotels. Stay tuned!"
|
||||||
|
image:
|
||||||
|
path: "blog1_title.png"
|
||||||
|
alt: "This is alt Text"
|
||||||
author: 'Tim'
|
author: 'Tim'
|
||||||
date: '11.06.2026'
|
date: '11.06.2026'
|
||||||
---
|
---
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
---
|
---
|
||||||
title: 'The second post'
|
title: 'The second post'
|
||||||
subtitle: 'In the second post we re talking about some nice luxury hotels. Stay tuned!'
|
subtitle: 'In the second post we re talking about some nice luxury hotels. Stay tuned!'
|
||||||
|
image:
|
||||||
|
path: "/assets/blog_img/blog2_title.png"
|
||||||
|
alt: "This is alt Text"
|
||||||
author: 'Tim'
|
author: 'Tim'
|
||||||
date: '12.06.2026'
|
date: '12.06.2026'
|
||||||
---
|
---
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
---
|
---
|
||||||
title: 'The third post'
|
title: 'The third post'
|
||||||
subtitle: 'In the third post we re talking about some nice luxury hotels. Stay tuned!'
|
subtitle: 'Lets go to Scandinavia. By bike! Hell yeah.'
|
||||||
|
description: "In the first post we're talking about some nice luxury hotels. Stay tuned!"
|
||||||
|
image:
|
||||||
|
path: "/assets/blog_img/blog3_title.png"
|
||||||
|
alt: "This is alt Text"
|
||||||
author: 'Elli'
|
author: 'Elli'
|
||||||
date: '13.06.2026'
|
date: '13.06.2026'
|
||||||
---
|
---
|
||||||
|
|
|
||||||
|
|
@ -23,4 +23,23 @@ body {
|
||||||
|
|
||||||
.nav-link:hover {
|
.nav-link:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-link-link {
|
||||||
|
text-decoration: none;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.headline {
|
||||||
|
margin-top: 8px;
|
||||||
|
margin-bottom: 0;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitle {
|
||||||
|
font-weight: lighter;
|
||||||
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
export interface Post {
|
export interface Post {
|
||||||
title: String,
|
title: String,
|
||||||
subtitle: String,
|
subtitle: String,
|
||||||
|
description: String,
|
||||||
date: String,
|
date: String,
|
||||||
author: String,
|
author: String,
|
||||||
|
image: {
|
||||||
|
path: string,
|
||||||
|
alt: string
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Reference in a new issue