perf: 文章分享支持分享方式配置

This commit is contained in:
mjsoftware 2024-02-08 15:36:48 +08:00
parent 33e0b50840
commit f64a970354
2 changed files with 15 additions and 3 deletions

View File

@ -45,7 +45,7 @@ const channels = {
} }
} }
function defaultConfig() { function defaultConfig(sites) {
return { return {
url: location.href, url: location.href,
origin: location.origin, origin: location.origin,
@ -57,7 +57,7 @@ function defaultConfig() {
// 图片或者图片所在的容器的选择器 // 图片或者图片所在的容器的选择器
imageSelector: undefined, imageSelector: undefined,
weiboKey: '', weiboKey: '',
sites: ['qq', 'qzone', 'wechat', 'weibo', 'douban', 'linkedin', 'facebook', 'twitter', 'google', 'link', 'poster'] sites: sites
} }
} }
@ -143,7 +143,7 @@ function triggerPosterShare(config) {
* @returns {*} * @returns {*}
*/ */
function buildConfig(options) { function buildConfig(options) {
const config = Object.assign(defaultConfig(), options) const config = Object.assign(defaultConfig(DreamConfig.post_share_sites), options)
if (!config.summary) { if (!config.summary) {
config.summary = config.description config.summary = config.description
} }

View File

@ -70,6 +70,18 @@
});'})] });'})]
/** 主题配置 */ /** 主题配置 */
const DreamConfig = {}; const DreamConfig = {};
/** 配置分享方式 */
let post_share = []
for (let share of [[${theme.config.post.custom_post_share}]]) {
let type = share.realNode.type;
if (post_share.indexOf(type) === -1) {
post_share.push(type);
}
}
if (post_share.length === 0) {
post_share.push('link');
}
DreamConfig["post_share_sites"] = post_share;
DreamConfig["theme_version"] = [[${theme.spec.version}]]; DreamConfig["theme_version"] = [[${theme.spec.version}]];
DreamConfig["theme_base"] = "[(${#theme.assets('/')})]"; DreamConfig["theme_base"] = "[(${#theme.assets('/')})]";
[(${!#strings.isEmpty(theme.config.post.code_fold_line)?'DreamConfig["code_fold_line"] = "' + theme.config.post.code_fold_line + '";': ''})] [(${!#strings.isEmpty(theme.config.post.code_fold_line)?'DreamConfig["code_fold_line"] = "' + theme.config.post.code_fold_line + '";': ''})]