summaryrefslogtreecommitdiff
path: root/web/src
diff options
context:
space:
mode:
authornavewindre <boneyaard@gmail.com>2026-02-11 02:05:39 +0100
committernavewindre <boneyaard@gmail.com>2026-02-11 02:05:39 +0100
commitd9d55620a6f4f44b2c5069da107b2b3b111390ed (patch)
treefbee83ccabeee18a04a691d61b60f68e98fa6553 /web/src
parent3032a8495174f4f583f52c4e9429b6d4d357dc0c (diff)
seo renderer
Diffstat (limited to 'web/src')
-rw-r--r--web/src/blog.tsx18
-rw-r--r--web/src/index-page.tsx3
-rw-r--r--web/src/index.html7
-rw-r--r--web/src/jsx.tsx20
4 files changed, 37 insertions, 11 deletions
diff --git a/web/src/blog.tsx b/web/src/blog.tsx
index bfef434..1fcfec2 100644
--- a/web/src/blog.tsx
+++ b/web/src/blog.tsx
@@ -8,12 +8,9 @@ let reqErr = 0;
let hljs = null;
let hljs_imported = 0;
-async function importHlJs() {
- if( hljs ) return;
- if( hljs_imported ) return;
- hljs_imported = 1;
- hljs = ( await import( 'highlight.js' ) ).default;
+async function highlightCode() {
+ if( !hljs || !hljs_imported ) return setTimeout( highlightCode, 500 );
const elements = $( "code" );
elements.each( ( _, e ) => {
@@ -21,6 +18,14 @@ async function importHlJs() {
} );
}
+async function importHlJs() {
+ if( hljs ) return;
+ if( hljs_imported ) return;
+
+ hljs_imported = 1;
+ hljs = ( await import( 'highlight.js' ) ).default;
+}
+
function urlForHref( href: string, isdir: boolean ) {
const url = new URL( window.location.href );
let path = url.pathname;
@@ -105,19 +110,20 @@ async function populatePost() {
$( "title" ).html( title );
}
- importHlJs();
$( "#package-entries" ).find( ".spinner" ).remove();
$( "#package-entries" ).css( "display", "none" );
$( "#blog-entry" ).html( text );
$( "#blog-entry" ).css( "display", "flex" );
$( "#back-btn" ).css( "display", "block" );
+ setTimeout( highlightCode );
} catch( e ) {
return populateEntries();
}
}
export default function Blog() {
+ importHlJs();
entries = [];
reqErr = 0;
setTimeout( async () => {
diff --git a/web/src/index-page.tsx b/web/src/index-page.tsx
index a754ef6..71a2fdc 100644
--- a/web/src/index-page.tsx
+++ b/web/src/index-page.tsx
@@ -3,6 +3,8 @@ import Home from "./home";
import Blog from "./blog";
import Pkgs from "./pkg";
+JSX.setDefaultTitle( "networkheaven.net" );
+
JSX.addRoute( "/", () => <Home /> );
JSX.addRoute( "/blog", () => <Blog /> );
JSX.addRoute( "/blog/*", () => <Blog /> );
@@ -10,6 +12,7 @@ JSX.addRoute( "/pkg", () => <Pkgs /> );
JSX.addRoute( "/pkg/*", () => <Pkgs /> );
window.onpopstate = JSX.onPopState;
+document.head.appendChild( <link rel="shortcut icon" href="/static/nh.ico" /> );
const url = new URL( window.location.href );
JSX.navigateParams( url.pathname, url.searchParams.entries() );
diff --git a/web/src/index.html b/web/src/index.html
index b14f5b5..68eba57 100644
--- a/web/src/index.html
+++ b/web/src/index.html
@@ -3,11 +3,14 @@
<head>
<meta charset="UTF-8">
<meta name="description" content="hi i'm aura and this is my website about stuff.">
- <meta name="viewport" content="width=device-width,user-scalable=yes">
+ <meta name="viewport" content="user-scalable=yes">
<title>networkheaven.net</title>
<link rel="stylesheet" href="/static/main.css">
<link href="/static/highlight.css" rel="preload" as="style" onload="this.rel='stylesheet'">
- <link rel="shortcut icon" href="/static/nh.ico" type="image">
+ <link rel="icon" href="data:image/png;base64,iVBORw0KGgo=">
+ <noscript>
+ <link rel="shortcut icon" href="/static/nh.ico" type="image">
+ </noscript>
</head>
<body>
<div id="moneyjsx-root">
diff --git a/web/src/jsx.tsx b/web/src/jsx.tsx
index a92fc11..749e93f 100644
--- a/web/src/jsx.tsx
+++ b/web/src/jsx.tsx
@@ -11,8 +11,9 @@ export interface Route {
const routes: Route[] = [];
let err404page = "/";
let rootId = "moneyjsx-root";
-let onprenavigate: Function = () => {};
-let onpostnavigate: Function = () => {};
+let defaultTitle = "";
+export let onprenavigate: Function = () => {};
+export let onpostnavigate: Function = () => {};
function routeForPath( route: string ) : Function | null {
if( !routes[route] ) {
@@ -37,6 +38,10 @@ export function setRootId( rootId: string ) {
rootId = rootId;
}
+export function setDefaultTitle( title: string ) {
+ defaultTitle = title;
+}
+
/**
* adds a route component to the routes list
* the component function must return either a jquery or a DOM element
@@ -87,6 +92,7 @@ export function navigate( route: string ) {
window.history.pushState( {}, null, url.href );
onprenavigate();
+ setTitle();
const el = $( cb() );
curRoute = cb;
@@ -111,6 +117,7 @@ export function navigateParams( route: string, params: any ) {
window.history.pushState( {}, null, url.href );
onprenavigate();
+ setTitle();
const el = $( cb() );
curRoute = cb;
@@ -143,6 +150,7 @@ export function navigateParamsSilent( route: string, params: any ) {
return navigateSilent( err404page );
onprenavigate();
+ setTitle();
const el = $( cb() );
curRoute = cb;
@@ -162,6 +170,7 @@ export function navigateSilent( route: string ) {
return navigateSilent( err404page );
onprenavigate();
+ setTitle();
const el = $( cb() );
curRoute = cb;
@@ -185,6 +194,7 @@ export function onPopState() {
return;
onprenavigate();
+ setTitle();
const el = $( cb() );
curRoute = cb;
@@ -251,7 +261,7 @@ export function createElement( tag: any, props: any, ...children: any ) {
const lowercaseName = name.toLowerCase();
if( lowercaseName in window ) {
- element.addEventListener( lowercaseName.substring(2 ), value );
+ element.addEventListener( lowercaseName.substring( 2 ), value );
continue;
}
}
@@ -288,3 +298,7 @@ export function createElement( tag: any, props: any, ...children: any ) {
export function createFragment( props: any ) {
return props.children;
}
+
+function setTitle() {
+ document.title = defaultTitle;
+}