mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-17 18:22:33 +00:00
Refactor next_font helper & NexT.utils.loadComments
This commit is contained in:
parent
bfa9a75440
commit
e953cbf4b0
2
layout/_third-party/comments/changyan.njk
vendored
2
layout/_third-party/comments/changyan.njk
vendored
@ -2,7 +2,7 @@
|
||||
<script id="cy_cmt_num" src="https://changyan.sohu.com/upload/plugins/plugins.list.count.js?clientId={{ theme.changyan.appid }}"></script>
|
||||
{% elif page.comments %}
|
||||
<script>
|
||||
NexT.utils.loadComments(document.querySelector('#SOHUCS'), () => {
|
||||
NexT.utils.loadComments('#SOHUCS', () => {
|
||||
NexT.utils.getScript('https://changyan.sohu.com/upload/changyan.js', () => {
|
||||
window.changyan.api.config({
|
||||
appid: '{{ theme.changyan.appid }}',
|
||||
|
||||
2
layout/_third-party/comments/disqus.njk
vendored
2
layout/_third-party/comments/disqus.njk
vendored
@ -20,7 +20,7 @@
|
||||
this.language = '{{ __('disqus') }}';
|
||||
{% endif -%}
|
||||
};
|
||||
NexT.utils.loadComments(document.querySelector('#disqus_thread'), () => {
|
||||
NexT.utils.loadComments('#disqus_thread', () => {
|
||||
if (window.DISQUS) {
|
||||
DISQUS.reset({
|
||||
reload: true,
|
||||
|
||||
2
layout/_third-party/comments/disqusjs.njk
vendored
2
layout/_third-party/comments/disqusjs.njk
vendored
@ -5,7 +5,7 @@
|
||||
{%- set disqusjs_js_uri = theme.vendors.disqusjs_js or '//cdn.jsdelivr.net/npm/disqusjs@1/dist/disqus.js' %}
|
||||
|
||||
<script>
|
||||
NexT.utils.loadComments(document.querySelector('#disqus_thread'), () => {
|
||||
NexT.utils.loadComments('#disqus_thread', () => {
|
||||
NexT.utils.getScript('{{ url_for(disqusjs_js_uri) }}', () => {
|
||||
window.dsqjs = new DisqusJS({
|
||||
api : '{{ theme.disqusjs.api }}' || 'https://disqus.com/api/',
|
||||
|
||||
2
layout/_third-party/comments/gitalk.njk
vendored
2
layout/_third-party/comments/gitalk.njk
vendored
@ -5,7 +5,7 @@
|
||||
{%- set gitalk_js_uri = theme.vendors.gitalk_js or '//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js' %}
|
||||
|
||||
<script>
|
||||
NexT.utils.loadComments(document.querySelector('#gitalk-container'), () => {
|
||||
NexT.utils.loadComments('#gitalk-container', () => {
|
||||
NexT.utils.getScript('{{ url_for(gitalk_js_uri) }}', () => {
|
||||
var gitalk = new Gitalk({
|
||||
clientID : '{{ theme.gitalk.client_id }}',
|
||||
|
||||
2
layout/_third-party/comments/livere.njk
vendored
2
layout/_third-party/comments/livere.njk
vendored
@ -1,6 +1,6 @@
|
||||
{%- if page.comments %}
|
||||
<script>
|
||||
NexT.utils.loadComments(document.querySelector('#lv-container'), () => {
|
||||
NexT.utils.loadComments('#lv-container', () => {
|
||||
window.livereOptions = {
|
||||
refer: location.pathname.replace(CONFIG.root, '').replace('index.html', '')
|
||||
};
|
||||
|
||||
2
layout/_third-party/comments/valine.njk
vendored
2
layout/_third-party/comments/valine.njk
vendored
@ -1,7 +1,7 @@
|
||||
{%- set valine_uri = theme.vendors.valine or '//cdn.jsdelivr.net/npm/valine@1/dist/Valine.min.js' %}
|
||||
|
||||
<script>
|
||||
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
|
||||
NexT.utils.loadComments('#valine-comments', () => {
|
||||
NexT.utils.getScript('{{ url_for(valine_uri) }}', () => {
|
||||
new Valine(Object.assign({
|
||||
el : '#valine-comments',
|
||||
|
||||
@ -11,13 +11,14 @@ hexo.extend.helper.register('next_font', function() {
|
||||
const fontHost = config.host || '//fonts.googleapis.com';
|
||||
|
||||
// Get a font list from config
|
||||
let fontFamilies = ['global', 'title', 'headings', 'posts', 'codes'].map(item => {
|
||||
let fontFamilies = [];
|
||||
['global', 'title', 'headings', 'posts', 'codes'].forEach(item => {
|
||||
if (config[item] && config[item].family && config[item].external) {
|
||||
return config[item].family + fontStyles;
|
||||
fontFamilies = fontFamilies.concat(config[item].family.split(','));
|
||||
}
|
||||
return '';
|
||||
}).filter(item => item !== '');
|
||||
});
|
||||
|
||||
fontFamilies = fontFamilies.map(name => name.trim() + fontStyles);
|
||||
fontFamilies = [...new Set(fontFamilies)].join('|');
|
||||
|
||||
// Merge extra parameters to the final processed font string
|
||||
|
||||
@ -71,7 +71,7 @@ $menu-item-bg-color-dark = $black-light;
|
||||
// --------------------------------------------------
|
||||
get_font_family(config) {
|
||||
$custom-family = hexo-config('font.' + config + '.family');
|
||||
return $custom-family is a 'string' ? $custom-family : null;
|
||||
return $custom-family is a 'string' ? unquote($custom-family) : null;
|
||||
}
|
||||
|
||||
// Font families.
|
||||
|
||||
@ -348,7 +348,8 @@ NexT.utils = {
|
||||
}
|
||||
},
|
||||
|
||||
loadComments: function(element, callback) {
|
||||
loadComments: function(selector, callback) {
|
||||
const element = document.querySelector(selector);
|
||||
if (!CONFIG.comments.lazyload || !element) {
|
||||
callback();
|
||||
return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user