feat: create initial website structure with content cards and star rating system
This commit is contained in:
parent
c2d4c58fb1
commit
91c6c529fc
10
content/books/the-midnight-library.md
Normal file
10
content/books/the-midnight-library.md
Normal 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"
|
||||||
|
---
|
||||||
10
content/movies/inception.md
Normal file
10
content/movies/inception.md
Normal 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"
|
||||||
|
---
|
||||||
10
content/recipes/spaghetti-carbonara.md
Normal file
10
content/recipes/spaghetti-carbonara.md
Normal 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"
|
||||||
|
---
|
||||||
10
content/tvseries/stranger-things.md
Normal file
10
content/tvseries/stranger-things.md
Normal 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"
|
||||||
|
---
|
||||||
10
content/youtube/tech-gadget-review.md
Normal file
10
content/youtube/tech-gadget-review.md
Normal 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"
|
||||||
|
---
|
||||||
@ -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;">☰</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>© {{ now.Format "2006" }} {{ .Site.Title }}</p>
|
|
||||||
</footer>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@ -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>
|
||||||
|
|
||||||
<h3>Recent Posts</h3>
|
|
||||||
<ul>
|
|
||||||
{{ range first 5 .Site.RegularPages.ByDate.Reverse }}
|
|
||||||
{{/* Only show pages from the 'post' section or other main sections */}}
|
|
||||||
{{ if eq .Section "post" }}
|
|
||||||
<li>
|
|
||||||
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
|
|
||||||
<p><small>Published: {{ .Date.Format "January 2, 2006" }}</small></p>
|
|
||||||
{{ .Summary }}
|
|
||||||
</li>
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
<div class="cards" id="cards">
|
||||||
|
{{ $current := "Books" }}
|
||||||
|
{{ range where .Site.RegularPages ".Params.category" $current }}
|
||||||
|
{{ partial "card.html" . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</div>
|
||||||
|
<script>
|
||||||
|
// Simple tab switching (client-side, not Hugo)
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
const tabs = document.querySelectorAll('.tab');
|
||||||
|
const cards = document.getElementById('cards');
|
||||||
|
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 }}
|
||||||
|
|||||||
8
layouts/partials/card.html
Normal file
8
layouts/partials/card.html
Normal 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">👍 {{ . }}</div>{{ end }}
|
||||||
|
<div class="card-desc">{{ .Params.description }}</div>
|
||||||
|
{{ with .Params.link }}<a class="card-link" href="{{ .url }}">{{ .label }} →</a>{{ end }}
|
||||||
|
</div>
|
||||||
10
layouts/partials/stars.html
Normal file
10
layouts/partials/stars.html
Normal 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 }}★{{ end }}
|
||||||
|
{{ if $half }}½{{ end }}
|
||||||
|
{{ range seq 1 $empty }}☆{{ end }}
|
||||||
|
</span>
|
||||||
120
static/css/style.css
Normal file
120
static/css/style.css
Normal 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%; }
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user