cirry

cirry

我的原生博客地址:https://cirry.cn

hexo(6)maupassant Theme Issue Summary

Many bugs in the current articles have been fixed in the new version#

Issue 1: mathjax CDN problem#

Every time it starts, you can see the following error in the console:

WARNING: cdn.mathjax.org has been retired. Check https://www.mathjax.org/cdn-shutting-down/ for migration tips.

It prompts us to switch the CDN link and modify the content in themes/maupassant/layout/_partial/mathjax.pug as follows:

script(type='text/javascript', src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML', async)

Issue 2: copycode button scrolls with the scrollbar#

This issue may occur only when using the npm package hexo-prism-plugin-advanced.

When the code block is too long, the copycode button may be covered by the code, making it difficult to click. Here, we add some top margin.

Add the following code to source/css/external.css created in the previous blog post:

pre[class*="language-"] {  
    padding-top: 2em;  
}  
  
pre[class*="language-"].line-numbers {  
    position: static;  
    padding-left: 3.8em;  
    counter-reset: linenumber;  
    overflow: auto;  
}

Also, modify the code in themes/maupassant/source/js/copycode.js. Find the two lines above and below where the code needs to be added, and add the middle line:

var successText = $(script).attr("successtext")  
$("pre").wrap('<div style=" position: relative;"></div>')   // Add this line
var copyHtml = '';

Issue 3: Add type inference to the highlight plugin#

Currently, if no language type is added to the code block, the rendered style will not have a frame.

Issue 4: Unable to enable level display in Waline comments#

I posted a Q&A to the author, and it has been fixed now.

Issue 5: Console error "fancybox is not function"#

The error is as follows:

image

The cause of the issue: It seems that the order of importing fancybox in the project is causing the problem. Since it does not affect the usage and does not occur every time, I did not investigate it further.

Solution:

  1. If you don't need this feature or don't know what this feature does, you can set fancybox: false in the theme's configuration file _config.maupassant.yml.
  2. If you really want to solve this problem, you can remove the async attribute from the tag that imports fancybox in themes/maupassant/layout/_partial/after_footer.pug.

The modified part of the code is as follows:

if theme.fancybox == true  
  script(type='text/javascript', src='//lib.baomitu.com/fancybox/latest/jquery.fancybox.min.js')  
  script(type='text/javascript', src=url_for(theme.js) + '/fancybox.js' + '?v=' + theme.version)  
  link(rel='stylesheet', type='text/css', href='//lib.baomitu.com/fancybox/latest/jquery.fancybox.min.css')

Note: If you want to learn more, you can visit the fancybox official website.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.