blog/static/post.tmpl

42 lines
1.5 KiB
Cheetah
Raw Normal View History

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{.Post.Title}}</title>
<link rel="icon" href="data:,">
<link rel="stylesheet" href="_/sakura.css"/>
</head>
<body>
<a style="position: absolute; left: 1em;" href="../../">Index</a>
{{.Post.Content}}
</body>
<script>
document.addEventListener('DOMContentLoaded', () => {
for (let level = 1; level <= 4; level++) {
let elems = document.getElementsByTagName("h" + level);
for (let i = 0; i < elems.length; i++) {
let elem = elems[i];
if (elem.id !== "undefined" && elem.id !== "") {
let anchorId = elem.id + "-anchor";
elem.addEventListener("mouseover", () => {
document.getElementById(anchorId).style.display = "initial";
});
elem.addEventListener("mouseout", () => {
document.getElementById(anchorId).style.display = "none";
});
let space = document.createElement("span");
space.innerText = " ";
elem.appendChild(space)
let anchor = document.createElement("a");
anchor.id = anchorId;
anchor.href = "#" + elem.id;
anchor.innerHTML = "<small>&para;</small>";
anchor.style.display = "none";
elem.appendChild(anchor);
}
}
}
});
</script>
</html>