Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
shlu committed Jan 9, 2025
1 parent a37ea1e commit d2d6aa3
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 2 deletions.
Binary file removed .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ footer-links:
pinterest:
rss: # just type anything here for a working RSS icon
twitter:
stackoverflow: # your stackoverflow profile, e.g. "users/50476/bart-kiers"
stackoverflow: users/12457105/shlu # your stackoverflow profile, e.g. "users/50476/bart-kiers"
youtube: # channel/<your_long_string> or user/<user-name>
googleplus: # anything in your profile username that comes after plus.google.com/
74 changes: 74 additions & 0 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,84 @@ <h1><a href="{{ "/" | absolute_url }}">{{ site.title }}</a></h1>

{{ content }}

{% if page.url != "/" %}
<blockquote>
<p>声明:转载请注明出处,原文地址:<a href="{{ site.url }}{{ page.url }}">{{ site.title }}</a></p>
</blockquote>
{% endif %}
<script>
(function() {
/**
* 使用 TreeWalker 遍历所有节点以查找注释节点
* @param {Document} doc - 要遍历的文档对象
* @returns {Array} - 包含所有注释节点的数组
*/
function getAllComments(doc) {
const comments = [];
const walker = doc.createTreeWalker(
doc,
NodeFilter.SHOW_COMMENT,
null,
false
);
let node;
while (node = walker.nextNode()) {
comments.push(node);
}
return comments;
}

/**
* 从注释内容中提取描述文本
* @param {string} comment - 注释文本内容
* @returns {string|null} - 提取的描述文本或 null
*/
function extractDescription(comment) {
const regex = /^description\s*:\s*(.+)$/i;
const match = comment.match(regex);
return match ? match[1].trim() : null;
}

// 等待 DOM 完全加载
document.addEventListener('DOMContentLoaded', function() {
const comments = getAllComments(document);
let descText = null;

// 遍历所有注释节点,查找匹配的描述注释
for (let commentNode of comments) {
const commentContent = commentNode.nodeValue.trim();
const extracted = extractDescription(commentContent);
if (extracted) {
descText = extracted;
break; // 找到第一个匹配的注释后退出循环
}
}

if (descText) {
// 更新 <meta name="description">
const metaDescription = document.querySelector('meta[name="description"]');
if (metaDescription) {
metaDescription.setAttribute('content', descText);
console.log('已更新 <meta name="description"> 内容为:', descText);
} else {
console.warn('未找到 <meta name="description"> 标签。');
}

// 更新 <meta property="og:description">
const metaOgDescription = document.querySelector('meta[property="og:description"]');
if (metaOgDescription) {
metaOgDescription.setAttribute('content', descText);
console.log('已更新 <meta property="og:description"> 内容为:', descText);
} else {
console.warn('未找到 <meta property="og:description"> 标签。');
}
} else {
console.warn('未找到符合格式的 description 注释(<!-- description: xxxxxx -->)。');
}
});
})();

</script>
<!-- comments config BEGIN -->

<!-- src="https://giscus.app/client.js" 自定义client.js-->
Expand Down
4 changes: 4 additions & 0 deletions git/git提交规范.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# GIT 提交规范

<!-- description: 介绍了GIT 提交的规范格式-->

## 1. 提交信息格式

Git 提交信息通常包含三部分:
Expand Down
5 changes: 5 additions & 0 deletions github/为Jekyll添加访问量显示.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 为Jekyll添加访问量显示

## 不蒜子计数

https://busuanzi.ibruce.info/
Original file line number Diff line number Diff line change
Expand Up @@ -499,4 +499,9 @@ long createAVMPInstance = (Long) dvmObject.getValue();
那么接下来直接调用目标函数

![在这里插入图片描述](./assets/b496142a482f4e4989d43626f527445c.jpeg)
这次终于调用成功了,并且结果与hook的是一致的,说明调用没有错误。完美,散花!!!
这次终于调用成功了,并且结果与hook的是一致的,说明调用没有错误。完美,散花!!!

------

**补充 By shlu:**

0 comments on commit d2d6aa3

Please sign in to comment.