From 8dfa36243322eaf9c944059597e42528133ed74e Mon Sep 17 00:00:00 2001 From: rain Date: Mon, 20 Jul 2026 10:57:15 +0800 Subject: [PATCH] fix: synchronize free article seo metadata --- html/mianfei.html | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/html/mianfei.html b/html/mianfei.html index 54bf608..2dad52e 100644 --- a/html/mianfei.html +++ b/html/mianfei.html @@ -3,6 +3,12 @@ + + + 神彩算 - 免费文章详情 @@ -273,6 +279,34 @@ }); } + function articlePlainText(value) { + var container = document.createElement("div"); + container.innerHTML = String(value || ""); + return String(container.textContent || container.innerText || "") + .replace(/\s+/g, " ") + .trim(); + } + + function updateArticleSeo(data) { + var title = articlePlainText(data && data.title) || "免费文章详情"; + var summarySource = + (data && (data.summary || data.description || data.introduction)) || + (data && data.content) || + "查看神彩算用户公开发布的免费彩票分析与预测文章,内容仅供学习与交流。"; + var description = articlePlainText(summarySource).slice(0, 160); + var descriptionMeta = document.querySelector('meta[name="description"]'); + var canonical = document.getElementById("canonicalUrl"); + + document.title = title + " - 神彩算"; + if (descriptionMeta && description) descriptionMeta.setAttribute("content", description); + if (canonical && articleId) { + canonical.setAttribute( + "href", + "https://www.scs8888.cn/mianfei/" + encodeURIComponent(articleId) + ".html", + ); + } + } + function renderArticle(data) { $("#articleTitle").text(data.title || "无标题"); $("#articleAuthor").text( @@ -282,7 +316,7 @@ ); $("#articleTime").text(data.updateTime || data.createTime || data.publishTime || "--"); $("#articleContent").html(scopeArticleContent(data.content || "")); - document.title = "神彩算 - " + (data.title || "免费文章详情"); + updateArticleSeo(data); renderArticleNav(data.prev || data.previous || data.prevArticle, data.next || data.nextArticle);