ppoffice / hexo-theme-hueman

A redesign of Alx's wordpress theme Hueman, ported to Hexo.
http://ppoffice.github.io/hexo-theme-hueman/
GNU General Public License v2.0
1.17k stars 335 forks source link

[ASK] Using lightgallery CDN #231

Closed arifpedia closed 6 years ago

arifpedia commented 6 years ago

Please make sure these boxes are checked before submitting your issue. Thank you!

I plan to use lightgallery CDN rather than local, so i edit file /layout/plugin/scripts.ejs:

<% if (typeof(isHead) !== 'undefined' && isHead) { %>
    <% if (theme.plugins.lightgallery) { %>
        <%- css('https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.6.11/css/lightgallery.min.css') %>
    <% } %>
    <% if (theme.plugins.justifiedgallery) { %>
        <%- css('https://cdnjs.cloudflare.com/ajax/libs/justifiedGallery/3.7.0/css/justifiedGallery.min.css') %>
    <% } %>
    <% if (theme.plugins.google_analytics) { %>
        <%- partial('plugin/google-analytics') %>
    <% } %>
    <% if (theme.plugins.baidu_analytics) { %>
        <%- partial('plugin/baidu-analytics') %>
    <% } %>
<% } else if (typeof(isFooter) !== 'undefined' && isFooter) { %>
    <% if (theme.plugins.statcounter && theme.plugins.statcounter.on) { %>
        <%- partial('plugin/statcounter') %>
    <% } %>
<% } else { %>
    <% if (theme.plugins.lightgallery) { %>
        <%- js('https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.6.11/js/lightgallery-all.min.js') %>
    <% } %>
    <% if (theme.plugins.justifiedgallery) { %>
        <%- js('https://cdnjs.cloudflare.com/ajax/libs/justifiedGallery/3.7.0/js/jquery.justifiedGallery.min.js') %>
    <% } %>
    <% if (theme.plugins.mathjax) { %>
        <script type="text/x-mathjax-config">
            MathJax.Hub.Config({ tex2jax: { inlineMath: [['$','$'], ['\\(','\\)']] } });
        </script>
        <%- js('https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML') %>
    <% } %>
<% } %>

But if i clicked on any image in the post, its open link directly (not using lightgallery): capture

ppoffice commented 6 years ago

@arifpedia Maybe you are using some new version of the lightGallery, and it isn't compatible with the code. You can check this out: https://github.com/ppoffice/hexo-theme-hueman/blob/master/source/libs/lightgallery/js/lightgallery.min.js

arifpedia commented 6 years ago

Fixed. jQuery must inserted before lightGallery. I recently change head.ejs:

...
    <%- js('https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js') %>
    <%- partial('plugin/scripts', { isHead: true }) %>
    </head>
...