format everything
All checks were successful
/ test (push) Successful in 13s

This commit is contained in:
Soph :3 2024-07-27 17:19:19 +03:00
parent 4aca2a7720
commit b260c88345
Signed by: sophie
GPG key ID: EDA5D222A0C270F2
4 changed files with 28 additions and 23 deletions

View file

@ -1,4 +1,4 @@
import Nano, { Component, Fragment, Suspense } from "nano-jsx" import Nano, { Component } from "nano-jsx"
import { BlogPage } from "./blog_page"; import { BlogPage } from "./blog_page";
import { Giscus } from "./giscus"; import { Giscus } from "./giscus";
import { useState } from "nano-jsx/esm/hooks/useState.js"; import { useState } from "nano-jsx/esm/hooks/useState.js";
@ -54,7 +54,7 @@ class Main extends Component {
} }
render(blogPosts: Metadata[]) { render(blogPosts: Metadata[]) {
const pageOpen = useState<Metadata | undefined>(undefined, "pageOpen"); const pageOpen = useState<Metadata | undefined>(undefined, "pageOpen");
const md = new URLSearchParams(location.search).get("md"); const md = new URLSearchParams(location.search).get("md");
let pageOpenValueRender = pageOpen[0]; let pageOpenValueRender = pageOpen[0];
@ -72,13 +72,13 @@ class Main extends Component {
} }
return <> return <>
<h1>blog & comments</h1> <h1>blog & comments</h1>
{() => { {() => {
if (blogPosts) return this.list(blogPosts) if (blogPosts) return this.list(blogPosts)
else return <h3>Loading...</h3> else return <h3>Loading...</h3>
}} }}
<Giscus searchTerm="main"></Giscus> <Giscus searchTerm="main"></Giscus>
</> </>
} }
} }

View file

@ -24,13 +24,13 @@ export class BlogPage extends Component {
render(blogPost: string) { render(blogPost: string) {
const pageOpen = useState<string | undefined>(undefined, "pageOpen"); const pageOpen = useState<string | undefined>(undefined, "pageOpen");
history.replaceState({}, "", location.pathname+"?md=" + this.metadata.filename); history.replaceState({}, "", location.pathname + "?md=" + this.metadata.filename);
return <> return <>
<h1>blog & comments</h1> <h1>blog & comments</h1>
<a style="font-size:xx-large;" onClick={() => { <a style="font-size:xx-large;" onClick={() => {
pageOpen[1](undefined); pageOpen[1](undefined);
history.replaceState({}, "", location.pathname+"?md="); history.replaceState({}, "", location.pathname + "?md=");
this.updateParent(); this.updateParent();
}}>return back?</a> }}>return back?</a>

View file

@ -29,10 +29,15 @@ class Particle {
this.x = x; this.x = x;
this.y = y; this.y = y;
this.id = Math.random(); this.id = Math.random();
this.angle = 2*Math.PI*this.id; this.angle = 2 * Math.PI * this.id;
this.color = "hsl(" + 360 * Math.random() + ',' + this.color =
(25 + 70 * Math.random()) + '%,' + "hsl(" +
(85 + 10 * Math.random()) + '%)'; 360 * Math.random() +
"," +
(25 + 70 * Math.random()) +
"%," +
(85 + 10 * Math.random()) +
"%)";
this.style = Math.random() < 0.5 ? "-" : Math.random() > 0.5 ? "+" : "*"; this.style = Math.random() < 0.5 ? "-" : Math.random() > 0.5 ? "+" : "*";
} }
@ -40,18 +45,18 @@ class Particle {
this.y += 2; this.y += 2;
this.x -= getRandomArbitrary(-1, 1); this.x -= getRandomArbitrary(-1, 1);
var width2=renderSurfaceContext.measureText("+").width; var width2 = renderSurfaceContext.measureText("+").width;
renderSurfaceContext.save(); renderSurfaceContext.save();
renderSurfaceContext.fillStyle = this.color; renderSurfaceContext.fillStyle = this.color;
renderSurfaceContext.font = Math.floor(this.id*60)+"px Arial"; renderSurfaceContext.font = Math.floor(this.id * 60) + "px Arial";
renderSurfaceContext.translate(this.x, this.y); renderSurfaceContext.translate(this.x, this.y);
renderSurfaceContext.rotate(2*Math.PI*this.id); renderSurfaceContext.rotate(2 * Math.PI * this.id);
renderSurfaceContext.fillText(this.style, -width2/2,4); renderSurfaceContext.fillText(this.style, -width2 / 2, 4);
renderSurfaceContext.restore(); renderSurfaceContext.restore();
if (renderSurface.height < this.y) { if (renderSurface.height < this.y) {
particles = particles.filter(z=>z.id !== this.id) particles = particles.filter((z) => z.id !== this.id);
} }
} }
} }

View file

@ -33,7 +33,7 @@ interface LatestStatus {
const parser = new DOMParser(); const parser = new DOMParser();
const doc = parser.parseFromString(await req.text(), "text/xml"); const doc = parser.parseFromString(await req.text(), "text/xml");
const latestEntryRaw = doc.querySelector("feed > entry"); const latestEntryRaw = doc.querySelector("feed > entry");
if (!latestEntryRaw) throw new Error("Missing latest entry!");; if (!latestEntryRaw) throw new Error("Missing latest entry!");
const latestEntry: LatestStatus = { const latestEntry: LatestStatus = {
username: doc.querySelector("feed > author > name")?.textContent!, username: doc.querySelector("feed > author > name")?.textContent!,
@ -46,7 +46,7 @@ interface LatestStatus {
.slice(0, -Math.min(latestEntry.status.length, 53)) .slice(0, -Math.min(latestEntry.status.length, 53))
.trim(); .trim();
const statusElement = document.getElementById("status"); const statusElement = document.getElementById("status");
if(!statusElement) throw new Error("Missing status element!"); if (!statusElement) throw new Error("Missing status element!");
const h2 = document.createElement("h2"); const h2 = document.createElement("h2");
const a = document.createElement("a"); const a = document.createElement("a");
const p = document.createElement("p"); const p = document.createElement("p");