summaryrefslogtreecommitdiff
path: root/web/src
diff options
context:
space:
mode:
Diffstat (limited to 'web/src')
-rw-r--r--web/src/blog.tsx28
-rw-r--r--web/src/home.tsx6
-rw-r--r--web/src/jsx.tsx4
3 files changed, 32 insertions, 6 deletions
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();
diff --git a/web/src/home.tsx b/web/src/home.tsx
index 217b7a4..422440b 100644
--- a/web/src/home.tsx
+++ b/web/src/home.tsx
@@ -12,9 +12,11 @@ export default function Home() {
<div style="width: 100%; display: flex; justify-content: center">
<div style="text-align: left; width: 75%">
<h5 style="margin-bottom: 0px;">
- hi, im aura and this is my website. check out my blog&nbsp;!!!
+ hi, im aura and this is my website. check out my <a href="/blog">blog</a>&nbsp;!!!
<br />
- i will add more stuff when i have time
+ i'm a 20something software engineer turned mechanic, i write about computers and cars.
+ <br />
+ i also host some <a href="/pkg">compiled packages</a> for slackware linux.
</h5>
</div>
</div>
diff --git a/web/src/jsx.tsx b/web/src/jsx.tsx
index 1243398..c6c491c 100644
--- a/web/src/jsx.tsx
+++ b/web/src/jsx.tsx
@@ -12,8 +12,8 @@ const routes: Route[] = [];
let err404page = "/";
let rootId = "moneyjsx-root";
let defaultTitle = "";
-export let onprenavigate: Function = () => {};
-export let onpostnavigate: Function = () => {};
+let onprenavigate: Function = () => {};
+let onpostnavigate: Function = () => {};
function routeForPath( route: string ) : Function | null {
if( !routes[route] ) {