Update some styles of my blog

This commit is contained in:
Daisuke Nakahara 2025-04-27 16:19:38 +09:00
parent c2ed18a27d
commit 69e344a4a5
6 changed files with 38 additions and 107 deletions

View file

@ -1,5 +1,4 @@
--- ---
import Social from "./Social.astro";
--- ---
<style> <style>
@ -8,8 +7,14 @@ import Social from "./Social.astro";
gap: 1rem; gap: 1rem;
margin-top: 2rem; margin-top: 2rem;
} }
.legal-information {
max-width: 800px;
margin: 0 auto;
text-align: center;
line-height: 1.6;
}
</style> </style>
<footer> <footer>
<Social platform="github" username="Daisuke897" /> <p class="legal-information">&copy; 2025 Nakahara Daisuke</p>
</footer> </footer>

View file

@ -1,13 +1,11 @@
--- ---
import Hamburger from "./Hamburger.astro"; import Hamburger from "./Hamburger.astro";
import Navigation from "./Navigation.astro"; import Navigation from "./Navigation.astro";
import ThemeIcon from './ThemeIcon.astro';
--- ---
<header> <header>
<nav> <nav>
<Hamburger /> <Hamburger />
<ThemeIcon />
<Navigation /> <Navigation />
</nav> </nav>
</header> </header>

View file

@ -1,73 +0,0 @@
---
---
<button id="themeToggle">
<svg width="30px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path
class="sun"
fill-rule="evenodd"
d="M12 17.5a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11zm0 1.5a7 7 0 1 0 0-14 7 7 0 0 0 0 14zm12-7a.8.8 0 0 1-.8.8h-2.4a.8.8 0 0 1 0-1.6h2.4a.8.8 0 0 1 .8.8zM4 12a.8.8 0 0 1-.8.8H.8a.8.8 0 0 1 0-1.6h2.5a.8.8 0 0 1 .8.8zm16.5-8.5a.8.8 0 0 1 0 1l-1.8 1.8a.8.8 0 0 1-1-1l1.7-1.8a.8.8 0 0 1 1 0zM6.3 17.7a.8.8 0 0 1 0 1l-1.7 1.8a.8.8 0 1 1-1-1l1.7-1.8a.8.8 0 0 1 1 0zM12 0a.8.8 0 0 1 .8.8v2.5a.8.8 0 0 1-1.6 0V.8A.8.8 0 0 1 12 0zm0 20a.8.8 0 0 1 .8.8v2.4a.8.8 0 0 1-1.6 0v-2.4a.8.8 0 0 1 .8-.8zM3.5 3.5a.8.8 0 0 1 1 0l1.8 1.8a.8.8 0 1 1-1 1L3.5 4.6a.8.8 0 0 1 0-1zm14.2 14.2a.8.8 0 0 1 1 0l1.8 1.7a.8.8 0 0 1-1 1l-1.8-1.7a.8.8 0 0 1 0-1z"
></path>
<path
class="moon"
fill-rule="evenodd"
d="M16.5 6A10.5 10.5 0 0 1 4.7 16.4 8.5 8.5 0 1 0 16.4 4.7l.1 1.3zm-1.7-2a9 9 0 0 1 .2 2 9 9 0 0 1-11 8.8 9.4 9.4 0 0 1-.8-.3c-.4 0-.8.3-.7.7a10 10 0 0 0 .3.8 10 10 0 0 0 9.2 6 10 10 0 0 0 4-19.2 9.7 9.7 0 0 0-.9-.3c-.3-.1-.7.3-.6.7a9 9 0 0 1 .3.8z"
></path>
</svg>
</button>
<style>
#themeToggle {
border: 0;
background: none;
}
.sun {
fill: black;
}
.moon {
fill: transparent;
}
:global(.dark) .sun {
fill: transparent;
}
:global(.dark) .moon {
fill: white;
}
</style>
<script is:inline>
const theme = (() => {
if (
typeof localStorage !== "undefined" &&
localStorage.getItem("theme")
) {
return localStorage.getItem("theme") ?? "light";
}
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
return "dark";
}
return "light";
})();
if (theme === "light") {
document.documentElement.classList.remove("dark");
} else {
document.documentElement.classList.add("dark");
}
window.localStorage.setItem("theme", theme);
const handleToggleClick = () => {
const element = document.documentElement;
element.classList.toggle("dark");
const isDark = element.classList.contains("dark");
localStorage.setItem("theme", isDark ? "dark" : "light");
};
document
.getElementById("themeToggle")
?.addEventListener("click", handleToggleClick);
</script>

View file

@ -17,7 +17,7 @@ const { pageTitle } = Astro.props;
<Header /> <Header />
<h1>{pageTitle}</h1> <h1>{pageTitle}</h1>
<slot /> <slot />
<Footer /> <Footer>
<script> <script>
import "../scripts/menu.js"; import "../scripts/menu.js";
</script> </script>

View file

@ -2,7 +2,7 @@
import BaseLayout from "../layouts/BaseLayout.astro"; import BaseLayout from "../layouts/BaseLayout.astro";
import BlogPost from "../components/BlogPost.astro"; import BlogPost from "../components/BlogPost.astro";
import { getCollection } from "astro:content"; import { getCollection } from "astro:content";
const pageTitle = "Naputo 学びを形に"; const pageTitle = "Naputo";
const allPosts = await getCollection("blog"); const allPosts = await getCollection("blog");
--- ---
@ -20,16 +20,25 @@ const allPosts = await getCollection("blog");
align-items: center; align-items: center;
margin-top: 2rem; margin-top: 2rem;
} }
.rounded-button { .list-of-articles-button {
padding: 10px 20px; display: inline-block;
background-color: rgba(192, 192, 192, 0.3); background-color: #e0e0e0;
border-radius: 10px; color: #333333;
font-size: 16px; font-size: 1rem;
font-weight: 600;
padding: 12px 24px;
border: none;
border-radius: 6px;
text-decoration: none;
transition: background-color 0.3s ease, transform 0.3s ease;
cursor: pointer;
}
.list-of-articles-button:hover {
background-color: #cacaca;
} }
</style> </style>
<BaseLayout pageTitle={pageTitle}> <BaseLayout pageTitle={pageTitle}>
<h2>20代のエンジニアによる技術や書評のアウトプットブログ</h2> <h3 class="header-new-posts">New Posts</h3>
<h3 class="header-new-posts">新しい記事</h3>
<div class="new-articles"> <div class="new-articles">
{ {
allPosts.slice(0, 6).map((post: any) => ( allPosts.slice(0, 6).map((post: any) => (
@ -47,6 +56,6 @@ const allPosts = await getCollection("blog");
</div> </div>
<div class="button-container"> <div class="button-container">
<a href="/blog/" class="rounded-button">記事の一覧</a> <a href="/blog/" class="list-of-articles-button">List of Article</a>
</div> </div>
</BaseLayout> </BaseLayout>

View file

@ -28,34 +28,35 @@ h1 {
.hamburger .line { .hamburger .line {
display: block; display: block;
width: 40px; width: 32px;
height: 5px; height: 4px;
margin-bottom: 10px; margin-bottom: 8px;
background-color: #ff9776; background-color: #333333;
} }
.nav-links { .nav-links {
width: 100%; width: 100%;
top: 5rem; display: flex;
left: 48px; justify-content: center;
background-color: #ff9776; align-items: center;
display: none;
margin: 0; margin: 0;
} }
.nav-links a { .nav-links a {
display: block; display: block;
text-align: center; text-align: center;
padding: 10px 0; padding: 10px 20px;
text-decoration: none; text-decoration: none;
font-size: 1.2rem; font-size: 1.2rem;
font-weight: bold; font-weight: bold;
text-transform: uppercase; text-transform: uppercase;
border-radius: 4px;
color: #333333;
} }
.nav-links a:hover, .nav-links a:hover,
.nav-links a:focus { .nav-links a:focus {
background-color: #ff9776; background-color: #e0e0e0;
} }
.expanded { .expanded {
@ -81,12 +82,3 @@ h1 {
} }
} }
html.dark {
background-color: #0d0950;
color: #fff;
}
.dark .nav-links a {
color: #fff;
}