Skip to content

Commit

Permalink
add area color identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
activatedgeek committed Mar 7, 2024
1 parent 492a407 commit 907bfd7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
18 changes: 18 additions & 0 deletions src/components/Header.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
---
import { getEntry } from "astro:content";
import { IoSearch } from "react-icons/io5";
import { PiTreeBold } from "react-icons/pi";
const { area } = Astro.props;
const {
data: { backgroundColor },
} = await getEntry(area.collection, area.id);
---

<style>
Expand All @@ -17,8 +24,19 @@ import { PiTreeBold } from "react-icons/pi";
margin-left: calc(var(--pico-spacing) * 0.5);
}
}

div.area-identifier {
width: 100vw;
height: calc(7 * var(--pico-border-width));
background-color: var(--area-background-color);
}
</style>

<div
class="area-identifier"
style={`--area-background-color: ${backgroundColor};`}
>
</div>
<header data-pagefind-ignore>
<nav>
<ul>
Expand Down
9 changes: 7 additions & 2 deletions src/components/Html.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Footer from "./Footer.astro";
import "@styles/main.css";
const {
frontmatter: { title, description, date, updated, keywords, authors },
frontmatter: { title, description, area, date, updated, keywords, authors },
} = Astro.props;
const canonicalURL = new URL(Astro.url.pathname, import.meta.env.SITE);
Expand All @@ -19,6 +19,10 @@ const authorsList = await Promise.all(
const {
data: { name: siteAuthorName },
} = await getEntry("authors", "sk");
const {
data: { backgroundColor: themeColor },
} = await getEntry(area.collection, area.id);
---

<html lang="en">
Expand All @@ -32,6 +36,7 @@ const {
<link rel="canonical" href={canonicalURL.href} />

<title>{title} | {siteAuthorName}</title>
<meta name="theme-color" content={themeColor} />
<meta name="description" content={description} />
{
authorsList.map(({ data: { name, url } }) => (
Expand Down Expand Up @@ -81,7 +86,7 @@ const {
<slot name="head" />
</head>
<body>
<Header />
<Header area={area} />
<slot />
<Footer />
</body>
Expand Down
1 change: 1 addition & 0 deletions src/pages/search.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Html from "@components/Html.astro";
const frontmatter = {
title: "Search",
authors: [{ collection: "authors", id: "sk" }],
area: { collection: "areas", id: "meta" },
date: new Date(),
};
Expand Down

0 comments on commit 907bfd7

Please sign in to comment.