feat: create initial website structure with content cards and star rating system

This commit is contained in:
Greg 2025-05-25 17:28:33 +02:00
parent c2d4c58fb1
commit 91c6c529fc
10 changed files with 228 additions and 25 deletions

View File

@ -0,0 +1,10 @@
---
title: "The Midnight Library"
category: "Books"
image: "/img/midnight-library.jpg"
rating: 4.0
description: "A novel about choices, regrets, and the infinite possibilities of life."
link:
url: "#"
label: "Learn more"
---

View File

@ -0,0 +1,10 @@
---
title: "Inception"
category: "Movies"
image: "/img/inception.jpg"
rating: 4.8
description: "A mind-bending thriller about dream invasion."
link:
url: "#"
label: "View details"
---

View File

@ -0,0 +1,10 @@
---
title: "Spaghetti Carbonara"
category: "Recipes"
image: "/img/carbonara.jpg"
rating: 5.0
description: "Classic Italian pasta dish with eggs, cheese, and pancetta."
link:
url: "#"
label: "Get recipe"
---

View File

@ -0,0 +1,10 @@
---
title: "Stranger Things"
category: "TV Series"
image: "/img/stranger-things.jpg"
rating: 4.2
description: "Kids in a small town uncover supernatural mysteries."
link:
url: "#"
label: "Explore series"
---

View File

@ -0,0 +1,10 @@
---
title: "Tech Gadget Review"
category: "YouTube"
image: "/img/tech-gadget.jpg"
likes: "1.2M Likes"
description: "Unboxing and review of the latest cool tech gadgets."
link:
url: "#"
label: "Watch video"
---

View File

@ -1,19 +1,22 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>{{ .Title }}</title> <meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="/css/style.css"> {{/* We'll create this later if needed */}} <title>{{ .Site.Title }}</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css?family=Roboto:400,500,700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/css/style.css">
</head> </head>
<body> <body>
<header> <header>
<h1><a href="{{ .Site.BaseURL }}">{{ .Site.Title }}</a></h1> <span style="font-size:1.7rem;cursor:pointer;margin-right:18px;">&#9776;</span>
<h1 style="margin:0;font-size:2rem;font-weight:500;">My Favorite Stuff</h1>
</header> </header>
<main> <main>
{{ block "main" . }}{{ end }} {{ block "main" . }}{{ end }}
</main> </main>
<footer> <div class="fab">+</div>
<p>&copy; {{ now.Format "2006" }} {{ .Site.Title }}</p>
</footer>
</body> </body>
</html> </html>

View File

@ -1,20 +1,32 @@
{{ define "main" }} {{ define "main" }}
<article> <div class="tabs" id="tabs">
<h2>{{ .Title }}</h2> {{ $categories := slice "Books" "Movies" "TV Series" "Recipes" "YouTube" "Music" "Concerts" }}
{{ .Content }} {{ range $i, $cat := $categories }}
</article> <div class="tab{{ if eq $i 0 }} active{{ end }}" data-tab="{{ $cat }}">{{ $cat }}</div>
{{ end }}
<h3>Recent Posts</h3> </div>
<ul> <div class="cards" id="cards">
{{ range first 5 .Site.RegularPages.ByDate.Reverse }} {{ $current := "Books" }}
{{/* Only show pages from the 'post' section or other main sections */}} {{ range where .Site.RegularPages ".Params.category" $current }}
{{ if eq .Section "post" }} {{ partial "card.html" . }}
<li> {{ end }}
<a href="{{ .RelPermalink }}">{{ .Title }}</a> </div>
<p><small>Published: {{ .Date.Format "January 2, 2006" }}</small></p> <script>
{{ .Summary }} // Simple tab switching (client-side, not Hugo)
</li> document.addEventListener('DOMContentLoaded', function() {
{{ end }} const tabs = document.querySelectorAll('.tab');
{{ end }} const cards = document.getElementById('cards');
</ul> const allCards = Array.from(cards.children);
tabs.forEach(tab => {
tab.addEventListener('click', function() {
tabs.forEach(t => t.classList.remove('active'));
this.classList.add('active');
const cat = this.getAttribute('data-tab');
allCards.forEach(card => {
card.style.display = card.innerHTML.includes(`category=\"${cat}\"`) ? '' : 'none';
});
});
});
});
</script>
{{ end }} {{ end }}

View File

@ -0,0 +1,8 @@
<div class="card">
{{ with .Params.image }}<img src="{{ . }}" alt="{{ $.Title }} cover">{{ end }}
<div class="card-title">{{ .Title }}</div>
{{ with .Params.rating }}<div class="card-rating">{{ partial "stars.html" (dict "rating" .) }} {{ . }}</div>{{ end }}
{{ with .Params.likes }}<div class="card-likes">&#128077; {{ . }}</div>{{ end }}
<div class="card-desc">{{ .Params.description }}</div>
{{ with .Params.link }}<a class="card-link" href="{{ .url }}">{{ .label }} &#8594;</a>{{ end }}
</div>

View File

@ -0,0 +1,10 @@
{{/* Renders stars for rating (e.g. 4.5) */}}
{{ $max := 5 }}
{{ $full := int (math.Floor .rating) }}
{{ $half := ge (modf .rating 1) 0.25 }}
{{ $empty := sub $max (add $full (cond $half 1 0)) }}
<span style="color:#fbc02d;">
{{ range seq 1 $full }}&#9733;{{ end }}
{{ if $half }}&#189;{{ end }}
{{ range seq 1 $empty }}&#9734;{{ end }}
</span>

120
static/css/style.css Normal file
View File

@ -0,0 +1,120 @@
body {
font-family: 'Roboto', Arial, sans-serif;
background: #f4f6fa;
margin: 0;
color: #222;
}
header {
background: #fff;
padding: 24px 32px 12px 32px;
box-shadow: 0 2px 8px rgba(0,0,0,0.03);
display: flex;
align-items: center;
gap: 16px;
}
header h1 {
font-size: 2rem;
margin: 0;
}
.tabs {
display: flex;
gap: 32px;
border-bottom: 2px solid #e0e5ec;
margin: 0 32px;
font-size: 1.1rem;
}
.tab {
padding: 12px 0;
cursor: pointer;
border-bottom: 2px solid transparent;
color: #666;
transition: border 0.2s, color 0.2s;
}
.tab.active {
border-bottom: 2px solid #1976d2;
color: #1976d2;
font-weight: 500;
}
.cards {
display: flex;
gap: 24px;
flex-wrap: wrap;
margin: 32px;
}
.card {
background: #fff;
border-radius: 16px;
box-shadow: 0 2px 8px rgba(0,0,0,0.07);
width: 240px;
padding: 0 0 20px 0;
display: flex;
flex-direction: column;
align-items: flex-start;
transition: box-shadow 0.2s;
}
.card:hover {
box-shadow: 0 6px 24px rgba(25, 118, 210, 0.09);
}
.card img {
width: 100%;
height: 180px;
object-fit: cover;
border-radius: 16px 16px 0 0;
}
.card-title {
font-size: 1.1rem;
font-weight: 500;
margin: 16px 0 0 16px;
}
.card-rating {
margin-left: 16px;
color: #fbc02d;
font-size: 1.1rem;
}
.card-desc {
margin: 8px 16px 0 16px;
color: #444;
font-size: 0.98rem;
}
.card-link {
margin: 10px 16px 0 16px;
color: #1976d2;
text-decoration: none;
font-weight: 500;
font-size: 0.97rem;
display: flex;
align-items: center;
gap: 4px;
}
.card-link:hover {
text-decoration: underline;
}
.card-likes {
margin-left: 16px;
color: #e53935;
font-size: 0.97rem;
display: flex;
align-items: center;
gap: 4px;
}
.fab {
position: fixed;
right: 32px;
bottom: 32px;
width: 56px;
height: 56px;
border-radius: 50%;
background: #1976d2;
color: #fff;
font-size: 2.2rem;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 4px 24px rgba(25, 118, 210, 0.18);
cursor: pointer;
z-index: 100;
}
@media (max-width: 900px) {
.cards { flex-direction: column; gap: 32px; }
.card { width: 100%; }
}