disclaimer about code that is not mine
This commit is contained in:
parent
0d30048b10
commit
482f5f90c0
@ -5,6 +5,9 @@ import { resolve, join } from "node:path";
|
||||
import { readdirSync, statSync, writeFileSync } from "node:fs";
|
||||
import { exec } from "node:child_process";
|
||||
|
||||
/*
|
||||
* Code from andii.dev
|
||||
*/
|
||||
const processFiles = () => {
|
||||
const outputFile = resolve("src/data/posts.json");
|
||||
const blogDir = resolve("src/routes/blog");
|
||||
|
@ -3,6 +3,9 @@ import { toString as nodeToString } from "hast-util-to-string";
|
||||
import { refractor } from "refractor";
|
||||
import tsx from "refractor/lang/tsx.js";
|
||||
|
||||
/*
|
||||
* Code from andii.dev
|
||||
*/
|
||||
refractor.register(tsx);
|
||||
|
||||
export const mdxPrism = () => {
|
||||
|
@ -1,5 +1,8 @@
|
||||
import type { ParentComponent } from "solid-js";
|
||||
|
||||
/*
|
||||
* Code from andii.dev
|
||||
*/
|
||||
export const Button: ParentComponent<{ onClick?: () => void }> = (props) => {
|
||||
return (
|
||||
<button class="button" type="button" onClick={props.onClick}>
|
||||
|
@ -1,69 +0,0 @@
|
||||
import { createSignal, onMount } from "solid-js";
|
||||
|
||||
export const DarkModeToggle = () => {
|
||||
let ref!: HTMLButtonElement;
|
||||
|
||||
const [dark, setDark] = createSignal(false);
|
||||
const size = 64;
|
||||
const max = 5;
|
||||
const time = 70;
|
||||
let direction = dark() ? -1 : 1;
|
||||
let current = dark() ? 0 : max;
|
||||
|
||||
onMount(() => {
|
||||
const isDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
||||
setDark(isDark);
|
||||
if (isDark) {
|
||||
direction = -1;
|
||||
current = 0;
|
||||
}
|
||||
requestAnimationFrame(() => {
|
||||
play();
|
||||
});
|
||||
});
|
||||
|
||||
const coord = (n: number) => -n * size;
|
||||
|
||||
const play = () => {
|
||||
ref.style.backgroundPositionX = `${coord(current)}px`;
|
||||
if (direction === -1 && current === 2) {
|
||||
document.documentElement.classList.add("dark");
|
||||
// ref.style.filter = "invert(0)";
|
||||
}
|
||||
if (direction === 1 && current === 3) {
|
||||
document.documentElement.classList.remove("dark");
|
||||
// ref.style.filter = "invert(1)";
|
||||
}
|
||||
if (direction === -1 && current === 0) return;
|
||||
if (direction === 1 && current === max) return;
|
||||
current += direction;
|
||||
setTimeout(play, time);
|
||||
};
|
||||
const toggle = () => {
|
||||
if (dark()) {
|
||||
direction = 1;
|
||||
} else {
|
||||
direction = -1;
|
||||
}
|
||||
play();
|
||||
setDark((d) => !d);
|
||||
};
|
||||
|
||||
return (
|
||||
<div class="absolute top-1v right-4h">
|
||||
<button
|
||||
onClick={toggle}
|
||||
ref={ref}
|
||||
class="pixelated"
|
||||
style={{
|
||||
scale: "1.5",
|
||||
height: "32px",
|
||||
width: "64px",
|
||||
"background-image": `url("/images/toggle.png")`,
|
||||
}}
|
||||
aria-hidden
|
||||
type="button"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
@ -1,6 +1,9 @@
|
||||
import { A } from "@solidjs/router";
|
||||
import type { ParentComponent } from "solid-js";
|
||||
|
||||
/*
|
||||
* Code from andii.dev
|
||||
*/
|
||||
function changeFavicon(newFaviconPath: string) {
|
||||
const link = document.querySelector("link[rel~='icon']") as HTMLLinkElement;
|
||||
if (link) {
|
||||
|
@ -8,6 +8,9 @@ import {
|
||||
onMount,
|
||||
} from "solid-js";
|
||||
|
||||
/*
|
||||
* Code from andii.dev
|
||||
*/
|
||||
const P: ParentComponent = (props) => <p class="mt-1v">{props.children}</p>;
|
||||
|
||||
const Ol: ParentComponent = (props) => (
|
||||
|
@ -2,6 +2,9 @@ import dayjs from "dayjs";
|
||||
import { type Component, For } from "solid-js";
|
||||
import type { Post } from "~/types";
|
||||
|
||||
/*
|
||||
* Code from andii.dev
|
||||
*/
|
||||
export const Posts: Component<{ posts: Post[] }> = (props) => {
|
||||
return (
|
||||
<ol class="">
|
||||
|
@ -3,6 +3,9 @@ import { type Component, For, Show } from "solid-js";
|
||||
type Node = { l: string; c: TreeNode[] };
|
||||
type TreeNode = string | Node;
|
||||
|
||||
/*
|
||||
* Code from andii.dev
|
||||
*/
|
||||
const Subtree: Component<{ tree: TreeNode }> = (props) => {
|
||||
return (
|
||||
<Show
|
||||
|
@ -9,6 +9,9 @@ import dayjs from "dayjs";
|
||||
import "../css/prism-nord.css";
|
||||
import type { Post } from "~/types";
|
||||
|
||||
/*
|
||||
* Code from andii.dev
|
||||
*/
|
||||
const Blog = (props: RouteSectionProps<unknown>) => {
|
||||
const meta = () =>
|
||||
posts.find((p) => props.location.pathname.endsWith(p.slug)) as Post;
|
||||
|
@ -1,6 +1,9 @@
|
||||
import { For } from "solid-js";
|
||||
import { tags } from "~/data/tags";
|
||||
|
||||
/*
|
||||
* Code from andii.dev
|
||||
*/
|
||||
const Tags = () => {
|
||||
return (
|
||||
<div>
|
||||
|
@ -4,6 +4,9 @@ import { posts } from "~/data/posts";
|
||||
import { Posts } from "~/components/Posts";
|
||||
import { tags } from "~/data/tags";
|
||||
|
||||
/*
|
||||
* Code from andii.dev
|
||||
*/
|
||||
const TagId: Component<RouteSectionProps<unknown>> = (props) => {
|
||||
const tag = () => tags[props.params.id];
|
||||
return (
|
||||
|
Loading…
x
Reference in New Issue
Block a user