feat: fix stuff

This commit is contained in:
Barrett Ruth 2025-05-22 19:03:58 -05:00
parent c08e4ce9d5
commit 90e139a22f
7 changed files with 26 additions and 17 deletions

View file

@ -1,5 +1,3 @@
import { getTopicColor } from "../../src/utils/colors.js";
const TERMINAL_PROMPT = "barrett@ruth:~$ ";
let typing = false;
let clearing = false;
@ -108,7 +106,7 @@ document.addEventListener("DOMContentLoaded", function () {
const topicName = topic.dataset.topic;
topic.addEventListener("mouseenter", () => {
const color = getTopicColor(topicName);
const color = window.getTopicColor(topicName);
topic.style.color = color;
});

View file

@ -1,5 +1,3 @@
import { getTopicColor } from "../../src/utils/colors.js";
function urlToTopic() {
const path = window.location.pathname;
const pathParts = path.split("/");
@ -84,7 +82,7 @@ function drawSolowGraph() {
.append("path")
.datum(outputData)
.attr("fill", "none")
.attr("stroke", getTopicColor(urlToTopic()))
.attr("stroke", window.getTopicColor(urlToTopic()))
.attr("stroke-width", 2)
.attr(
"d",
@ -267,7 +265,7 @@ function drawRomerGraph() {
.append("path")
.datum(romerData)
.attr("fill", "none")
.attr("stroke", getTopicColor(urlToTopic()))
.attr("stroke", window.getTopicColor(urlToTopic()))
.attr("stroke-width", 2)
.attr(
"d",
@ -360,7 +358,7 @@ function drawRomerlGraph() {
.append("path")
.datum(romerData)
.attr("fill", "none")
.attr("stroke", getTopicColor(urlToTopic()))
.attr("stroke", window.getTopicColor(urlToTopic()))
.attr("stroke-width", 2)
.attr(
"d",
@ -506,7 +504,7 @@ function drawRomerSolowGraph() {
.append("path")
.datum(romerSolowData)
.attr("fill", "none")
.attr("stroke", getTopicColor(urlToTopic()))
.attr("stroke", window.getTopicColor(urlToTopic()))
.attr("stroke-width", 2)
.attr(
"d",
@ -603,7 +601,7 @@ function drawRomerSolowChangeGraph() {
.append("path")
.datum(romerSolowData)
.attr("fill", "none")
.attr("stroke", getTopicColor(urlToTopic()))
.attr("stroke", window.getTopicColor(urlToTopic()))
.attr("stroke-width", 2)
.attr(
"d",

View file

@ -3,6 +3,10 @@ title: "designing this website"
date: "18/06/2024"
---
## Update: Port to Astro (<span class="date">22/05/2025</span>)
hi
## HTML, JavaScript, and CSS
That's all there is to it.

View file

@ -27,6 +27,20 @@ const {
<slot />
</main>
<Footer />
<script is:inline>
window.getTopicColor = function(topicName) {
switch (topicName) {
case "software":
return "#0073e6";
case "algorithms":
return "#d50032";
case "meditations":
return "#6a0dad";
default:
return "#000000";
}
};
</script>
<slot name="scripts" />
</body>
</html>

View file

@ -91,14 +91,10 @@ const capitalizedCategory =
</style>
<script define:vars={{ category }}>
import { getTopicColor } from "../utils/colors.js";
document.addEventListener("DOMContentLoaded", function () {
document.documentElement.style.setProperty(
"--topic-color",
getTopicColor(category),
window.getTopicColor(category),
);
window.getTopicColor = getTopicColor;
});
</script>

View file

@ -1,7 +1,6 @@
---
import BaseLayout from "../layouts/BaseLayout.astro";
import { getCollection } from "astro:content";
import { getTopicColor } from "../utils/colors.js";
const title = "Barrett Ruth";

View file

@ -9,4 +9,4 @@ export function getTopicColor(topicName) {
default:
return "#000000";
}
}
}