-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add share.js support #1095
Add share.js support #1095
Conversation
Thanks so much for opening your first PR here! |
Thanks. Let's wait for jsdelivr to update this package 😂 https://www.jsdelivr.com/package/npm/social-share.js
|
@@ -1,6 +1,7 @@ | |||
.post-widgets { | |||
border-top: 1px solid #eee; | |||
margin-top: 45px; | |||
padding-top: 20px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change for what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, would you commit much more? I sae you mark resolved upstairs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{%- if theme.likely.enable or (theme.needmoreshare2.enable and theme.needmoreshare2.postbottom.enable) %} | ||
<div class="social-share"> | ||
{%- if theme.likely.enable or (theme.needmoreshare2.enable and theme.needmoreshare2.postbottom.enable) or theme.sharejs.enable %} | ||
<div class="post-social-share"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No additional changes, add extra judgment for sharejs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{%- if theme.sharejs.enable %}
<div class="social-share" data-sites="{{ theme.sharejs.networks }}" data-wechat-qrcode-title="{{ __(theme.sharejs.wechat_qrcode.title) }}" data-wechat-qrcode-helper="{{ __(theme.sharejs.wechat_qrcode.prompt) }}"></div>
{%- endif %}
Or you can put options to front-end, we have global CONFIG, check head.swig.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed css class social-share
to post-social-share
because share.js has hard-coded selector for social-share
, which is exactly the same and will definitely result in problems if multiple share components are enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I performed a global search to make sure that no css code selects for social-share
, I think it's necessary to introduce this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{%- if theme.sharejs.enable %} <div class="social-share" data-sites="{{ theme.sharejs.networks }}" data-wechat-qrcode-title="{{ __(theme.sharejs.wechat_qrcode.title) }}" data-wechat-qrcode-helper="{{ __(theme.sharejs.wechat_qrcode.prompt) }}"></div> {%- endif %}
Or you can put options to front-end, we have global CONFIG, check head.swig.
Is it suitable to put configuration scripts to _partials/share/sharejs.swig
? Code may be injected to all pages even if no share components present, or should I put it under _partials/post/post_footer.swig
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forget this, you can check likely, css/html/js part is independent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, keep these share services unified, If you have more ideas, open another PR when this merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I performed a global search to make sure that no css code selects for social-share, I think it's necessary to introduce this change.
.social-share
will be blocked by adblock, but .post-social-share
won't.
How about using jsdelivr as default CDN: https://cdn.jsdelivr.net/npm/social-share.js@1/dist/js/social-share.min.js |
can the version number of all cdn verder be replaced by @latest |
Besides, social-share.js was last published 3 years ago: https://www.npmjs.com/package/social-share.js This is a potential problem. Gitment and Han have not been updated for more than a year, they have brought a lot of issues and finally be removed from NexT.
|
My suggestion is to maintain a fork of share.js by NexT. Thus we can remove the hard-coded selector for |
Thanks for your contributing. New plugin created: https://github.com/theme-next/hexo-next-share
|
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Added support for share.js.
Issue resolved: N/A
What is the new behavior?
How to use?
In NexT
_config.yml
:Does this PR introduce a breaking change?