Skip to content

Commit

Permalink
updates stule header
Browse files Browse the repository at this point in the history
  • Loading branch information
chinacomx committed Jun 3, 2024
1 parent ffea598 commit 3dad937
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 31 deletions.
39 changes: 17 additions & 22 deletions _layouts/home.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
---
layout: default
---
<div class="splash">
<div class="splash-content">
<img src="{{ '/assets/images/logo.png' | relative_url }}" alt="Project Logo">
<h1>ChinaComX</h1>
<p>Exploring beyond the Silk Road</p>
<a href="#posts" class="scroll-down">&#8595;</a>
</div>
</div>
<section id="posts" class="content">
<div class="container">
<h2>Latest Posts</h2>
{% for post in site.posts %}
<article>
<h3><a href="{{ post.url | relative_url }}">{{ post.title }}</a></h3>
<p>{{ post.excerpt }}</p>
</article>
{% endfor %}
</div>
</section>
<!DOCTYPE html>
<html lang="en" class="home">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ page.title | default: site.title }}</title>
<link rel="stylesheet" href="{{ '/assets/css/style.css' | relative_url }}">
</head>
<body class="home">
{% include header.html %}
<main>
{{ content }}
</main>
{% include footer.html %}
<script src="{{ '/assets/js/main.js' | relative_url }}"></script>
</body>
</html>
7 changes: 5 additions & 2 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ header {
width: 100%;
top: 0;
left: 0;
display: none;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
z-index: 1000;
transition: top 0.3s;
}

header.hide {
display: none;
}

header.show {
display: block;
}
Expand Down Expand Up @@ -80,7 +83,7 @@ header nav ul li a {
}

.content {
padding: 2em 0;
padding: 4em 0 2em;
}

footer {
Expand Down
20 changes: 13 additions & 7 deletions assets/js/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
document.addEventListener("DOMContentLoaded", function() {
const header = document.getElementById("header");
window.addEventListener("scroll", function() {
if (window.scrollY > 0) {
header.classList.add("show");
} else {
header.classList.remove("show");
}
});
if (document.body.classList.contains('home')) {
window.addEventListener("scroll", function() {
if (window.scrollY > 0) {
header.classList.remove("hide");
header.classList.add("show");
} else {
header.classList.remove("show");
header.classList.add("hide");
}
});
} else {
header.classList.add("show");
}
});
19 changes: 19 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,22 @@
layout: home
title: Home
---
<div class="splash">
<div class="splash-content">
<img src="{{ '/assets/images/logo.png' | relative_url }}" alt="Project Logo">
<h1>ChinaComX</h1>
<p>Comics Culture in the People's Republic of China</p>
<a href="#posts" class="scroll-down">&#8595;</a>
</div>
</div>
<section id="posts" class="content">
<div class="container">
<h2>Latest Posts</h2>
{% for post in site.posts %}
<article>
<h3><a href="{{ post.url | relative_url }}">{{ post.title }}</a></h3>
<p>{{ post.excerpt }}</p>
</article>
{% endfor %}
</div>
</section>

0 comments on commit 3dad937

Please sign in to comment.