Minor fixes for TOC
This commit is contained in:
+3
-1
@@ -20,7 +20,9 @@
|
|||||||
li.className = "toc-" + h.tagName.toLowerCase();
|
li.className = "toc-" + h.tagName.toLowerCase();
|
||||||
var a = document.createElement("a");
|
var a = document.createElement("a");
|
||||||
a.href = "#" + h.id;
|
a.href = "#" + h.id;
|
||||||
a.textContent = h.textContent;
|
var clone = h.cloneNode(true);
|
||||||
|
clone.querySelectorAll(".btn, .muted").forEach(function (el) { el.remove(); });
|
||||||
|
a.textContent = clone.textContent.trim();
|
||||||
li.appendChild(a);
|
li.appendChild(a);
|
||||||
list.appendChild(li);
|
list.appendChild(li);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -483,17 +483,14 @@ func renderDiaryMonth(fsPath, urlPath string) template.HTML {
|
|||||||
for _, dayNum := range days {
|
for _, dayNum := range days {
|
||||||
date := time.Date(year, time.Month(monthNum), dayNum, 0, 0, 0, 0, time.UTC)
|
date := time.Date(year, time.Month(monthNum), dayNum, 0, 0, 0, 0, time.UTC)
|
||||||
|
|
||||||
heading := formatGermanDate(date)
|
heading := date.Format("2006-01-02")
|
||||||
dayURL := path.Join(urlPath, fmt.Sprintf("%02d", dayNum)) + "/"
|
dayURL := path.Join(urlPath, fmt.Sprintf("%02d", dayNum)) + "/"
|
||||||
var content template.HTML
|
var content template.HTML
|
||||||
if dirName, ok := dayDirs[dayNum]; ok {
|
if dirName, ok := dayDirs[dayNum]; ok {
|
||||||
dayURL = path.Join(urlPath, dirName) + "/"
|
dayURL = path.Join(urlPath, dirName) + "/"
|
||||||
dayFsPath := filepath.Join(fsPath, dirName)
|
dayFsPath := filepath.Join(fsPath, dirName)
|
||||||
if raw, err := os.ReadFile(filepath.Join(dayFsPath, "index.md")); err == nil && len(raw) > 0 {
|
if raw, err := os.ReadFile(filepath.Join(dayFsPath, "index.md")); err == nil && len(raw) > 0 {
|
||||||
if h := extractFirstHeading(raw); h != "" {
|
|
||||||
heading = h
|
|
||||||
raw = stripFirstHeading(raw)
|
raw = stripFirstHeading(raw)
|
||||||
}
|
|
||||||
content = renderMarkdown(raw)
|
content = renderMarkdown(raw)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user