blog/layouts/home.html
2025-05-13 22:24:24 +02:00

335 lines
15 KiB
HTML

<!DOCTYPE html>
<html lang="{{ site.Language }}" dir="{{ .Language.LanguageDirection | default "auto" }}">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta charset="utf-8">
<!-- Include core CSS files -->
<link rel="stylesheet" href="{{ "css/core/reset.css" | relURL }}">
<link rel="stylesheet" href="{{ "css/core/theme-vars.css" | relURL }}">
<link rel="stylesheet" href="{{ "css/core/zmedia.css" | relURL }}">
<!-- Include concatenated and minified stylesheet -->
{{- $theme_vars := (resources.Get "css/core/theme-vars.css") }}
{{- $reset := (resources.Get "css/core/reset.css") }}
{{- $media := (resources.Get "css/core/zmedia.css") }}
{{- $license_css := (resources.Get "css/core/license.css") }}
{{- $common := (resources.Match "css/common/*.css") | resources.Concat "assets/css/common.css" }}
{{- $core := (slice $theme_vars $reset $common $media) | resources.Concat "assets/css/core.css" | resources.Minify }}
<link rel="stylesheet" href="{{ $core.RelPermalink }}">
<style>
body {
margin: 0;
padding: 0;
display: flex;
justify-content: center; /* Center the main-screen horizontally */
align-items: stretch; /* Ensure full height */
min-height: 100vh; /* Ensure the body takes up the full viewport height */
}
.main-screen {
display: flex;
flex-direction: row;
justify-content: space-between; /* Ensure side-screens are adjacent to main-content */
width: auto; /* Allow the width to adjust based on content */
max-width: 100%; /* Prevent overflow */
gap: 0;
text-align: justify;
}
.side-screen {
height: 100vh;
overflow-y: auto; /* Allow scrolling if content overflows */
flex: 0 0 400px; /* Fixed width of 400px */
}
.main-content {
display: flex;
flex-direction: column;
flex-grow: 1; /* Take up the remaining space between side-screens */
max-width: 900px; /* Optional: Limit max width */
margin: 0 25px;
}
.header {
display: flex;
justify-content: space-between; /* Space between the title and navigation */
align-items: center; /* Align items vertically in the center */
padding: 10px 20px; /* Optional: Add some padding */
}
.title-wrapper {
display: flex;
flex-direction: row;
gap: 10px;
justify-content: space-between;
}
.site-title {
flex-grow: 1;
margin: 0; /* Remove default margin */
font-size: 3rem; /* Adjust font size as needed */
}
.navigation {
flex-grow: 3;
display: flex;
}
.presentation, .side-content-column > * {
background-color: var(--entry);
padding: 10px;
border-radius: var(--radius);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.center-content, .side-content-column {
display: flex;
flex-grow: 1; /* Allow it to grow */
gap: 20px; /* Optional: Add spacing between child elements */
}
.presentation, .side-content-column {
flex: 1; /* Make both elements take up equal width */
}
.presentation {
max-width: 100%; /* Ensure it doesn't exceed its container */
}
.presentation a {
text-decoration: underline;
}
.side-content-column {
max-width: 100%; /* Ensure it doesn't exceed its container */
flex-direction: column;
}
.excerpt {
display: flex;
align-items: center; /* Align items vertically in the center */
gap: 10px; /* Add spacing between text and image */
}
.excerpt-text {
flex: 1; /* Allow text to take up remaining space */
}
.excerpt img {
flex-shrink: 0; /* Prevent the image from shrinking */
max-width: 150px; /* Ensure the image doesn't exceed its intended size */
height: auto; /* Maintain aspect ratio */
}
@media (max-width: 1450px) {
.side-screen {
display: none; /* Hide side-screens on smaller screens */
}
.main-screen {
justify-content: center; /* Center main-content when side-screens are hidden */
}
}
/* Media query for when main-content is less than 700px wide */
@media (max-width: 700px) {
.center-content, .header{
flex-direction: column; /* Stack elements vertically */
}
.presentation, .side-content-column, .site-title, .navigation{
flex: none; /* Reset flex property */
width: 100%; /* Make them take full width */
}
}
</style>
</head>
<header>
<!-- Script to automatically toggle to the right theme -->
{{- /* theme-toggle is enabled */}}
{{- if (not site.Params.disableThemeToggle) }}
{{- /* theme is light */}}
{{- if (eq site.Params.defaultTheme "light") }}
<script>
if (localStorage.getItem("pref-theme") === "dark") {
document.body.classList.add('dark');
}
</script>
{{- /* theme is dark */}}
{{- else if (eq site.Params.defaultTheme "dark") }}
<script>
if (localStorage.getItem("pref-theme") === "light") {
document.body.classList.remove('dark')
}
</script>
{{- else }}
{{- /* theme is auto */}}
<script>
if (localStorage.getItem("pref-theme") === "dark") {
document.body.classList.add('dark');
} else if (localStorage.getItem("pref-theme") === "light") {
document.body.classList.remove('dark')
} else if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.body.classList.add('dark');
}
</script>
{{- end }}
{{- /* theme-toggle is disabled and theme is auto */}}
{{- else if (and (ne site.Params.defaultTheme "light") (ne site.Params.defaultTheme "dark"))}}
<script>
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.body.classList.add('dark');
}
</script>
{{- end }}
</header>
<body>
<div class="main-screen">
<div class="side-screen">
{{ partial "posts-defile.html" (dict "context" . "direction" "up") }}
</div>
<div class="main-content">
<div class="header">
<div class="title-wrapper">
<h1 class="site-title">Achille Toupin</h1>
{{- if (not site.Params.disableThemeToggle) }}
<button id="theme-toggle" accesskey="t" title="(Alt + T)" aria-label="Toggle theme">
<svg id="moon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"
stroke-linejoin="round">
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path>
</svg>
<svg id="sun" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"
stroke-linejoin="round">
<circle cx="12" cy="12" r="5"></circle>
<line x1="12" y1="1" x2="12" y2="3"></line>
<line x1="12" y1="21" x2="12" y2="23"></line>
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
<line x1="1" y1="12" x2="3" y2="12"></line>
<line x1="21" y1="12" x2="23" y2="12"></line>
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
</svg>
</button>
{{- end }}
</div>
<nav class="navigation">
{{ partial "menu.html" }}
</nav>
</div>
<div class="center-content">
<div class="presentation">
{{ .Content }}
</div>
<div class="side-content-column">
<div class="dernier-article">
{{ range first 1 (where .Site.RegularPages.ByDate.Reverse "Section" "blog") }}
{{- $image := .Resources.GetMatch (printf "%s" .Params.cover.image) -}}
{{- if $image -}}
{{- $optimizedImage := $image.Fill "150x150 webp q95 Center" -}}
<a href="{{ .RelPermalink }}">
<h2>Mon dernier article :</h2>
<h3>{{ .Title }}</h3>
<div class="excerpt">
<div class="excerpt-text">
<small>{{ .Date.Format "January 2, 2006" }}</small>
<p>{{ .Plain | plainify | truncate 100 }}</p>
</div>
<img src="{{ $optimizedImage.RelPermalink }}" alt="{{ .Title }} cover image"></img>
</div>
</a>
{{ end }}
{{ end }}
</div>
<div class="dernier-article">
{{ range first 1 (where .Site.RegularPages.ByDate.Reverse "Section" "collection") }}
{{- $image := .Resources.GetMatch (printf "%s" .Params.cover.image) -}}
{{- if $image -}}
{{- $optimizedImage := $image.Fit "150x150 webp q95 Center" -}}
<a href="{{ .RelPermalink }}">
<h2>Une belle machine :</h2>
<h3>{{ .Title }}</h3>
<div class="excerpt">
<div class="excerpt-text">
<small>{{ .Date.Format "January 2, 2006" }}</small>
<p>{{ .Plain | plainify | truncate 100 }}</p>
</div>
<img src="{{ $optimizedImage.RelPermalink }}" alt="{{ .Title }} cover image"></img>
</div>
</a>
{{ end }}
{{ end }}
</div>
<div class="dernier-livre">
{{ range first 1 (where .Site.RegularPages.ByDate.Reverse "Section" "livres") }}
{{- $image := .Resources.GetMatch (printf "%s" .Params.cover.image) -}}
{{- if $image -}}
{{- $optimizedImage := $image.Fit "150x150 webp q95 Center" -}}
<a href="{{ .RelPermalink }}">
<h2>Lecture du moment :</h2>
<h3>{{ .Title }}</h3>
<div class="excerpt">
<div class="excerpt-text">
<small>{{ .Date.Format "January 2, 2006" }}</small>
<p>{{ .Plain | plainify | truncate 100 }}</p>
</div>
<img src="{{ $optimizedImage.RelPermalink }}" alt="{{ .Title }} cover image"></img>
</div>
</a>
{{ end }}
{{ end }}
</div>
</div>
</div>
{{ partial "buttons.html"}}
{{ partialCached "footer.html" . .Layout .Kind (.Param "hideFooter") (.Param "ShowCodeCopyButtons") -}}
</div>
<div class="side-screen">
{{ partial "posts-defile.html" (dict "context" . "direction" "down") }}
</div>
</div>
</body>
<footer>
<!-- Script to toggle theme. has to be at the end of the page -->
{{- if (not site.Params.disableThemeToggle) }}
<script>
document.addEventListener("DOMContentLoaded", () => {
const themeToggleButton = document.getElementById("theme-toggle");
if (themeToggleButton) {
themeToggleButton.addEventListener("click", () => {
if (document.body.className.includes("dark")) {
document.body.classList.remove('dark');
localStorage.setItem("pref-theme", 'light');
} else {
document.body.classList.add('dark');
localStorage.setItem("pref-theme", 'dark');
}
});
} else {
console.error("Theme toggle button not found");
}
});
</script>
<script>
const observer = new MutationObserver(() => {
const themeToggleButton = document.getElementById("theme-toggle");
if (themeToggleButton) {
observer.disconnect(); // Stop observing once the button is found. Explanation :
/*
the .theme-toggle button is being rendered dynamically (e.g., via a Hugo partial or JavaScript),
so it might not exist in the DOM when the script runs.
To handle this, you can use a MutationObserver to detect when the button is added to the DOM
*/
themeToggleButton.addEventListener("click", () => {
if (document.body.className.includes("dark")) {
document.body.classList.remove('dark');
localStorage.setItem("pref-theme", 'light');
} else {
document.body.classList.add('dark');
localStorage.setItem("pref-theme", 'dark');
}
});
}
});
observer.observe(document.body, { childList: true, subtree: true });
</script>
{{- end }}
</footer>
</html>