SEO: custom share template (canonical, per-page OG, JSON-LD, robots), robots.txt, OG banner; generator sets shareOpenGraphURL; ignis module STEP example

This commit is contained in:
trilium-share-gruvbox
2026-08-28 16:54:32 +02:00
parent e13a5433d9
commit 71d6311e49
9 changed files with 416 additions and 5 deletions
+12 -5
View File
@@ -356,19 +356,26 @@ function run() {
}
}
function ensureShareDescription() {
function ensureSeoMeta() {
const seen = new Set();
(function walk(note, depth) {
if (depth > 20) return;
for (const child of note.getChildNotes()) {
if (seen.has(child.noteId)) continue;
seen.add(child.noteId);
if (child.getLabelValue("publish") === "true") {
const desc = child.getLabelValue("summary") || SITE_DESCRIPTION;
const published = child.getLabelValue("publish") === "true";
const isCat = isCategoryNote(child);
if (published || isCat) {
const desc = child.getLabelValue("summary") || (isCat ? "Articles in " + child.title : SITE_DESCRIPTION);
if (child.getLabelValue("shareDescription") !== desc) {
child.setLabel("shareDescription", desc);
child.save();
api.log("blog_generator: set shareDescription on " + child.title);
}
const url = SHARE_BASE + "/" + encodeURIComponent(child.getLabelValue("shareAlias") || child.noteId);
if (child.getLabelValue("shareOpenGraphURL") !== url) {
child.setLabel("shareOpenGraphURL", url);
child.save();
api.log("blog_generator: set shareOpenGraphURL on " + child.title);
}
}
walk(child, depth + 1);
@@ -598,7 +605,7 @@ function run() {
buildCategories();
buildStateMap();
buildSitemap();
ensureShareDescription();
ensureSeoMeta();
buildBlogData();
removeEmptyCategories();
}