mirror of
https://github.com/Fechin/reference.git
synced 2026-11-21 13:34:06 +03:00
Formats all the general js files. Separate in case these should be treated differently for any reason. This commit includes all javascript and HTML files.
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
const { encodeURL } = require("hexo-util");
|
|
|
|
hexo.extend.helper.register("share_link", function (type) {
|
|
let title = this.page_title();
|
|
let description = this.page_description();
|
|
let url = this.url_for(this.url);
|
|
let link = "";
|
|
switch (type) {
|
|
case "facebook":
|
|
link = `https://facebook.com/sharer/sharer.php?u=${url}`;
|
|
break;
|
|
case "twitter":
|
|
link = `https://twitter.com/intent/tweet/?text=${description}&url=${url}`;
|
|
break;
|
|
case "linkedin":
|
|
link = `https://www.linkedin.com/shareArticle?url=${url}&title=${title}&summary=${description}`;
|
|
break;
|
|
case "reddit":
|
|
link = `https://reddit.com/submit/?url=${url}&resubmit=true&title=${description}`;
|
|
break;
|
|
case "pinterest":
|
|
link = `https://pinterest.com/pin/create/button/?url=${url}&description=${description}`;
|
|
break;
|
|
case "mail":
|
|
link = `mailto:?subject=${title}&body=\n${description}\n\n${url}`;
|
|
break;
|
|
case "line":
|
|
link = `https://social-plugins.line.me/lineit/share?url=${url}`;
|
|
break;
|
|
}
|
|
return encodeURL(link);
|
|
});
|