mirror of
https://github.com/Fechin/reference.git
synced 2026-11-21 05:24:10 +03:00
29 lines
1.1 KiB
JavaScript
29 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;
|
|
}
|
|
return encodeURL(link);
|
|
}); |