Skip to content

Commit c7901f7

Browse files
committed
feat(page): custom h tag icon
1 parent c512a95 commit c7901f7

File tree

3 files changed

+42
-5
lines changed

3 files changed

+42
-5
lines changed

docs/.vuepress/config.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,21 @@ module.exports = {
810810
showAddMood: true,
811811

812812
//生成海报的顶部图片api接口,请注意,该接口需要直接返回图片地址,不能有跨域问题,设置之前,可以先使用ajax看是否存在跨域
813-
postImgApi: 'https://picture.cco.vin/pic/rmimg?type=bing'
813+
postImgApi: 'https://picture.cco.vin/pic/rmimg?type=bing',
814+
815+
/*
816+
* 以下为v1.5.4新增功能
817+
* */
818+
819+
//文章h2标签的icon
820+
articleH2Icon: '🌸',
821+
822+
//文章h3标签的icon
823+
articleH3Icon: '🐳',
824+
825+
//文章h4标签及h4标签之后的标签的icon
826+
articleH4Icon: '⛄',
827+
814828

815829
/*
816830
* 下面这些是在v1.3.2中移除的配置,但是在V1.3.2之前的版本中,可能还可以使用,某些配置我不确定具体在哪个

docs/.vuepress/theme/lib/client/components/Page.vue

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,27 @@ export default defineComponent({
257257
let medium_zoom_content_h3Tag = document.querySelectorAll(".medium-zoom-content h3 a");
258258
let medium_zoom_content_h4Tag = document.querySelectorAll(".medium-zoom-content h4 a,.medium-zoom-content h5 a,.medium-zoom-content h6 a");
259259
for (let i = 0; i < medium_zoom_content_h2Tag.length; i++) {
260-
medium_zoom_content_h2Tag[i].innerText = "🌸"
260+
if (this.themeProperty.articleH2Icon !== undefined) {
261+
medium_zoom_content_h2Tag[i].innerText = this.themeProperty.articleH2Icon
262+
}else {
263+
medium_zoom_content_h2Tag[i].innerText = "🌸"
264+
}
261265
}
262266
263267
for (let i = 0; i < medium_zoom_content_h3Tag.length; i++) {
264-
medium_zoom_content_h3Tag[i].innerText = "🐳"
268+
if (this.themeProperty.articleH3Icon !== undefined) {
269+
medium_zoom_content_h3Tag[i].innerText = this.themeProperty.articleH3Icon
270+
}else {
271+
medium_zoom_content_h3Tag[i].innerText = "🐳"
272+
}
265273
}
266274
267275
for (let i = 0; i < medium_zoom_content_h4Tag.length; i++) {
268-
medium_zoom_content_h4Tag[i].innerText = ""
276+
if (this.themeProperty.articleH4Icon !== undefined) {
277+
medium_zoom_content_h4Tag[i].innerText = this.themeProperty.articleH4Icon
278+
}else {
279+
medium_zoom_content_h4Tag[i].innerText = ""
280+
}
269281
}
270282
})
271283
}

docs/.vuepress/theme/lib/client/components/child/Catalog.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
:class="{catalogChildrenActive: catalogChildrenActive === itemLevel2Index }"
2424
class="catalog-page-children-item">
2525
<div class="catalog-page-children-title">
26-
<router-link :to="itemLevel1.path + '#' + itemLevel2.title">
26+
<!--<router-link :to="itemLevel1.path + '#' + itemLevel2.title">-->
27+
<router-link :to="getCatalogPath(itemLevel1.path,itemLevel2.title)">
2728
<span @click="clickCatalogTitle" :slug="itemLevel2.slug">{{itemLevel2.title}}</span>
2829
</router-link>
2930
</div>
@@ -86,6 +87,16 @@ export default {
8687
}
8788
},
8889
computed: {
90+
getCatalogPath() {
91+
return (path,title) => {
92+
let pathSubstr = path.substr(path.length -1,1);
93+
if (pathSubstr === "/") {
94+
path = path.substr(0,path.length -1)
95+
}
96+
97+
return path + "#" + title
98+
}
99+
},
89100
getCatalogLevel1Title() {
90101
return (itemLevel1) => {
91102
let title = itemLevel1.title

0 commit comments

Comments
 (0)