From 5d8ff6e73b2734c33badf09321fa346a6d144a49 Mon Sep 17 00:00:00 2001
From: navewindre <boneyaard@gmail.com>
Date: Mon, 16 Feb 2026 18:50:27 +0100
Subject: cleanup

---
 web/src/blog.tsx | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

(limited to 'web/src/blog.tsx')

diff --git a/web/src/blog.tsx b/web/src/blog.tsx
index 738dd7c..745afde 100644
--- a/web/src/blog.tsx
+++ b/web/src/blog.tsx
@@ -9,6 +9,8 @@ let reqErr = 0;
 let hljs = null;
 let hljs_imported = 0;
 
+const page_meta = $( "meta[name=description]" ).attr( "content" );
+
 async function highlightCode() {
   if( !hljs || !hljs_imported ) return setTimeout( highlightCode, 500 );
 
@@ -92,6 +94,22 @@ function populateEntries() {
   }
 }
 
+function updateMeta( is_post: boolean ) {
+  if( is_post ) {
+    const entry = $( "#blog-entry" );
+    if( !entry.length )
+      return;
+
+    let text = entry[0].innerText;
+    if( text.length > 300 )
+      text = text.slice( 0, 300 ) + "...";
+
+    $( "meta[name='description']" ).attr( "content", text );
+  } else {
+    $( "meta[name='description']" ).attr( "content", page_meta );
+  }
+}
+
 async function populatePost() {
   try {
     const res = await fetch( "https://networkheaven.net/" + getEndpoint() + ".html" );
@@ -107,17 +125,18 @@ async function populatePost() {
       let title = text.substring( titles + 7, titlee - 1 );
       title = title.replace( /\n/g, "" );
       $( ".page-title h3" )[0].innerText = title;
-      $( "title" ).html( title );
+      $( "title" ).html( title + " - networkheaven.net" );
     }
 
-
     $( "#package-entries" ).find( ".spinner" ).remove();
     $( "#package-entries" ).css( "display", "none" );
     $( "#blog-entry" ).html( text );
     $( "#blog-entry" ).css( "display", "flex" );
     $( "#back-btn" ).css( "display", "block" );
+    updateMeta( true );
     setTimeout( highlightCode );
   } catch( e ) {
+    updateMeta( false );
     return populateEntries();
   }
 }
@@ -134,6 +153,11 @@ export default function Blog() {
     }
   } );
 
+  JSX.onPreNavigate( () => {
+    updateMeta( false );
+    JSX.onPreNavigate( () => {} );
+  } );
+
   setTimeout( () => {
     if( getEndpoint() == 'posts/' )
       return populateEntries();
-- 
cgit v1.2.3

