Skip to content

Commit 45e41e4

Browse files
committed
centralized meta tags, update home page
1 parent 0f6d234 commit 45e41e4

10 files changed

Lines changed: 57 additions & 28 deletions

File tree

blog.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
<link rel="stylesheet" href="css/shared.css" />
1919
<link rel="stylesheet" href="css/blog.css" />
20+
<template id="meta-include" data-src="components/meta-tags.html"></template>
2021

2122
<meta http-equiv="Content-Security-Policy" content="
2223
default-src 'self';

components/header.html

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,11 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8">
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>Robin's Site</title>
7-
<meta name="robots" content="index,follow">
8-
<meta name="generator" content="noai">
9-
<meta name="ai" content="noai">
10-
<meta name="robots" content="noai,noimageai">
11-
<meta http-equiv="X-Robots-Tag" content="noai,noimageai">
12-
<link rel="stylesheet" href="styles.css">
13-
</head>
14-
<body>
15-
<div class="header-title"><span id="site-brand">Robin's Site </span><span id="fs-path">~/</span></div>
16-
<nav>
17-
<a href="index.html">Home</a> |
18-
<a href="projects.html">Projects</a> |
19-
<a href="notes.html">Notes</a> |
20-
<a href="blog.html">Blog</a>
21-
</nav>
22-
<div class="header-row">
23-
<p>Welcome! Sharing ideas, projects, school notes, and more.</p>
24-
<button id="theme-toggle" aria-label="Toggle Dark Mode">Dark Mode</button>
25-
</div>
26-
<script src="script.js"></script>
27-
</body>
28-
</html>
1+
<div class="header-title"><span id="site-brand">Robin's Site </span><span id="fs-path">~/</span></div>
2+
<nav>
3+
<a href="index.html">Home</a> |
4+
<a href="projects.html">Projects</a> |
5+
<a href="notes.html">Notes</a> |
6+
<a href="blog.html">Blog</a>
7+
</nav>
8+
<div class="header-row">
9+
<p>Welcome! Sharing ideas, projects, school notes, and more.</p>
10+
<button id="theme-toggle" aria-label="Toggle Dark Mode">Dark Mode</button>
11+
</div>

components/meta-tags.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!-- Centralized meta tags include -->
2+
<meta name="robots" content="index,follow" />
3+
<meta name="generator" content="noai" />
4+
<meta name="ai" content="noai" />
5+
<meta name="robots" content="noai,noimageai" />
6+
<meta http-equiv="X-Robots-Tag" content="noai,noimageai" />
7+
<meta name="referrer" content="no-referrer" />
8+
<meta name="color-scheme" content="light dark" />

course.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<title>Course - Robin's Site</title>
88
<link rel="stylesheet" href="css/shared.css">
99
<link rel="stylesheet" href="css/notes.css">
10+
<template id="meta-include" data-src="components/meta-tags.html"></template>
1011
</head>
1112

1213
<body>

index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<meta charset="UTF-8" />
1515
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
1616
<title>Robin's Site</title>
17+
<template id="meta-include" data-src="components/meta-tags.html"></template>
1718
<link rel="stylesheet" href="css/shared.css" />
1819
<link rel="stylesheet" href="css/home.css" />
1920
<meta http-equiv="Content-Security-Policy" content="
@@ -36,6 +37,11 @@ <h1>Hello, I'm Robin.</h1>
3637
to document my thoughts, projects, and anything else I find worth sharing. I share random ideas and
3738
stuff I created about school, life, etc. (Not any type of category that I want to fall into, journal,
3839
diary, because it would feel kind of restrictive on 'how'/'what' should I write about anything.)
40+
<br><br>
41+
If you are viewing this using a text based browser, unfortunately, you won't be able to see most of
42+
the content here as I heavily rely on JavaScript to render the content dynamically, and I'm too lazy
43+
to add a static fallback. (I found out this problem when I was trying to use Lynx to view my site
44+
yesterday. Why did I try to do that? Good question.)
3945
</p>
4046

4147
<h2>What You Might Find Here</h2>

js/header-footer.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,32 @@ function loadHeaderFooter() {
1414
}
1515

1616
document.addEventListener("DOMContentLoaded", () => {
17+
// Inject centralized meta tags if template present
18+
const metaTpl = document.getElementById('meta-include');
19+
if (metaTpl && metaTpl.dataset.src) {
20+
fetch(metaTpl.dataset.src)
21+
.then(r => r.text())
22+
.then(fragment => {
23+
const tempDiv = document.createElement('div');
24+
tempDiv.innerHTML = fragment;
25+
// Avoid duplicate robots/meta by removing any existing with same name/http-equiv
26+
const incoming = Array.from(tempDiv.children);
27+
incoming.forEach(el => {
28+
if (el.tagName === 'META') {
29+
const name = el.getAttribute('name');
30+
const equiv = el.getAttribute('http-equiv');
31+
if (name) {
32+
document.head.querySelectorAll(`meta[name="${name}"]`).forEach(e => e.remove());
33+
}
34+
if (equiv) {
35+
document.head.querySelectorAll(`meta[http-equiv="${equiv}"]`).forEach(e => e.remove());
36+
}
37+
document.head.appendChild(el);
38+
}
39+
});
40+
})
41+
.catch(() => { /* silent fail */ });
42+
}
1743
loadHeaderFooter().then(() => {
1844
initializeThemeToggle();
1945
const yearEl = document.getElementById("current-year");

note.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<title>Note - Robin's Site</title>
2020
<link rel="stylesheet" href="css/shared.css" />
2121
<link rel="stylesheet" href="css/notes.css" />
22+
<template id="meta-include" data-src="components/meta-tags.html"></template>
2223
<link id="hljs-light" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@11.7.0/styles/github.min.css">
2324
<link id="hljs-dark" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@11.7.0/styles/github-dark.min.css" disabled>
2425

notes.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
<link rel="stylesheet" href="css/shared.css" />
1919
<link rel="stylesheet" href="css/notes.css" />
20+
<template id="meta-include" data-src="components/meta-tags.html"></template>
2021

2122
<meta http-equiv="Content-Security-Policy" content="
2223
default-src 'self';

post.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<link rel="stylesheet" href="css/post.css" />
2020
<link id="hljs-light" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@11.7.0/styles/github.min.css">
2121
<link id="hljs-dark" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@11.7.0/styles/github-dark.min.css" disabled>
22+
<template id="meta-include" data-src="components/meta-tags.html"></template>
2223

2324
<script src="https://cdn.jsdelivr.net/npm/highlight.js@11.7.0/lib/highlight.min.js"></script>
2425

projects.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<link rel="stylesheet" href="css/shared.css" />
1818
<link rel="stylesheet" href="css/home.css" />
1919
<link rel="stylesheet" href="css/projects.css" />
20+
<template id="meta-include" data-src="components/meta-tags.html"></template>
2021
<meta http-equiv="Content-Security-Policy" content="
2122
default-src 'self';
2223
script-src 'self' https://cdn.jsdelivr.net;

0 commit comments

Comments
 (0)