defualt post layout

This commit is contained in:
Sveske_Juice 2024-02-26 20:43:42 +01:00
parent 110720ea59
commit 3d36a59d36
5 changed files with 85 additions and 15 deletions

View File

@ -11,15 +11,8 @@ export function load() {
// Sort by newest news first // Sort by newest news first
posts.sort((a, b) => b.creation_date - a.creation_date); posts.sort((a, b) => b.creation_date - a.creation_date);
posts.map((post) => { posts.forEach((post) => {
let summary : Post = { summaries.push(post);
url: post.url,
title : post.title,
summary : post.summary,
creation_date : post.creation_date,
modification_date : post.modification_date
};
summaries.push(summary);
}); });
return { summaries }; return { summaries };

View File

@ -63,7 +63,7 @@
<footer> <footer>
<div class="about-container"> <div class="about-container">
<div class="credits"> <div class="credits">
<span>© 2023-2024 Developed by:</span> <span>© 2023-2024</span>
<br> <br>
<span>Benjamin Dreyer</span> <span>Benjamin Dreyer</span>
<br> <br>

View File

@ -3,10 +3,80 @@
import { type BlogData } from './+layout'; import { type BlogData } from './+layout';
export let data : BlogData export let data : BlogData
const monthNames : string[] = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"];
function humanDate(date : Date) : string {
return `${date.getDate()} ${monthNames[date.getMonth()]} ${date.getFullYear()}`;
}
</script> </script>
{#if data} <article>
<h3>{data.post.title}</h3> <div class="body">
{/if} <header>
<img id="blog-cover-img" src={data.post.cover_img} alt={data.post.cover_alt} />
<h3 id="title">{data.post.title}</h3>
<div class="dates">
<span class="date">Created {humanDate(new Date(+data.post.creation_date * 1000))}</span>
<span class="date">Last Modified {humanDate(new Date(+data.post.modification_date * 1000))}</span>
</div>
</header>
<div class="content">
<slot />
</div>
</div>
</article>
<slot />
<style>
article {
margin-top: 25px;
margin-inline: auto;
max-width: 1000px;
/* background: var(--background1); */
}
header {
display: flex;
flex-direction: column;
margin-bottom: 50px;
}
#blog-cover-img {
aspect-ratio: 16 / 9;
max-width: 100%;
border-radius: 0.5rem;
}
#title {
font-family: var(--title-font);
font-size: 36px;
margin: 0;
}
.dates {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
gap: 10px;
}
.date {
color: var(--text3);
}
.body {
margin-inline: auto;
max-width: 1200px;
padding: 25px;
}
.content {
line-height: 2;
font-size: 18px;
text-rendering: optimizeLegibility;
}
</style>

View File

@ -2,6 +2,8 @@
export type Post = { export type Post = {
// Required // Required
url : string, url : string,
cover_img : string,
cover_alt : string,
title: string, title: string,
summary : string, summary : string,
creation_date : number creation_date : number
@ -9,12 +11,13 @@ export type Post = {
// Optional // Optional
// TODO: author? // TODO: author?
// TODO: image cover
} }
export const posts : Post[] = [ export const posts : Post[] = [
{ {
url: 'folder-icons', url: 'folder-icons',
cover_img: '/images/posts/folder-icons/cover.png',
cover_alt: 'Image of folder icons being used in the editor',
title: 'Amazing Icons for Folders in Unity!', title: 'Amazing Icons for Folders in Unity!',
summary: 'See how you can use Zhen\'s folder icons for Unity to boost your developer experience', summary: 'See how you can use Zhen\'s folder icons for Unity to boost your developer experience',
creation_date: 1708382491, creation_date: 1708382491,
@ -22,6 +25,8 @@ export const posts : Post[] = [
}, },
{ {
url: 'lorem', url: 'lorem',
cover_img: '/images/posts/folder-icons/cover.png',
cover_alt: 'Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat.',
title: 'Lorem Ipsum !!', title: 'Lorem Ipsum !!',
summary: 'This is a nice exploanation on lorem ipsum latin', summary: 'This is a nice exploanation on lorem ipsum latin',
creation_date: 1708382491, creation_date: 1708382491,
@ -29,6 +34,8 @@ export const posts : Post[] = [
}, },
{ {
url: 'lorem1', url: 'lorem1',
cover_img: '/images/posts/folder-icons/cover.png',
cover_alt: 'Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat.',
title: 'Idk some arcticle bruh!', title: 'Idk some arcticle bruh!',
summary: 'Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat.', summary: 'Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat.',
creation_date: 1708558377, creation_date: 1708558377,

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB