Skip to content

Commit

Permalink
Merge pull request #37 from Lruihao/watermark
Browse files Browse the repository at this point in the history
Add Watermark plugin (#35)
  • Loading branch information
Lruihao authored Dec 11, 2021
2 parents 96aface + de7bb0d commit f0dfdb7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "public"]
path = public
url = git@github.com:Lruihao/lruihao.github.io.git
[submodule "assets/lib/watermark"]
path = assets/lib/watermark
url = https://github.com/Lruihao/watermark.git
30 changes: 23 additions & 7 deletions assets/js/_custom.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* @author LRUIHAO.CN
* @author @Lruihao https://lruihao.cn
* @description Custom javascript for hugo-blog.
*/
const CustomJS = new (function () {
/**
* Baidu auto push.
* @link https://ziyuan.baidu.com
* @returns CustomJS
* @returns {CustomJS}
*/
this.baiduPush = () => {
var bp = document.createElement('script');
Expand All @@ -23,7 +23,7 @@ const CustomJS = new (function () {
/**
* Baidu statistics.
* @link https://tongji.baidu.com
* @returns CustomJS
* @returns {CustomJS}
*/
this.baiduStatistics = () => {
var _hmt = _hmt || [];
Expand All @@ -35,7 +35,7 @@ const CustomJS = new (function () {
};
/**
* Console some infomation
* @returns CustomJS
* @returns {CustomJS}
*/
this.consoleInfo = () => {
console.log(
Expand All @@ -52,7 +52,7 @@ const CustomJS = new (function () {
/**
* Fix the toc bug.
* @link https://github.com/Lruihao/hugo-blog/issues/24
* @returns CustomJS
* @returns {CustomJS}
*/
this.fixToc = () => {
$toc = document.querySelector('#toc-auto');
Expand All @@ -64,14 +64,30 @@ const CustomJS = new (function () {
}
return this;
};
/**
* Render watermark.
* @link https://github.com/Lruihao/watermark
* @returns {CustomJS}
*/
this.renderWatermark = () => {
new Watermark({
content: '@Lruihao',
opacity: 0.03
});
return this;
};

/**
* Initialize.
* @returns CustomJS
* @returns {CustomJS}
*/
this.init = () => {
// SEO etc.
this.baiduStatistics().baiduPush();
this.fixToc().consoleInfo();
// Bug fixs.
this.fixToc();
// Custom infos.
this.consoleInfo().renderWatermark();
return this;
};
})();
Expand Down
1 change: 1 addition & 0 deletions assets/lib/watermark
Submodule watermark added at fb1059
10 changes: 6 additions & 4 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -455,12 +455,14 @@ theme = "LoveIt"
# someCSS = "https://cdn.example.com/some.css"
[params.page.library.js]
# someJavascript = "some.js"
# located in "assets/"
# Or
# someJavascript = "https://cdn.example.com/some.js"
customJS = "js/_custom.js"
# located in "assets/" Or URL
# The names are in alphabetical order.
# pangu.js@latest https://github.com/vinta/pangu.js
panguJS = "https://cdn.jsdelivr.net/npm/pangu@latest/dist/browser/pangu.min.js"
# watermark@1.0.2 https://github.com/Lruihao/watermark
watermark = "lib/watermark/watermark.js"
# Custom Javascript
z-customJS = "js/_custom.js"
# Page SEO config
[params.page.seo]
# image URL
Expand Down

0 comments on commit f0dfdb7

Please sign in to comment.