众所周知,在去年年底,知名的免费cdn服务提供商jsdelivr由于大陆域名备案的问题,没有国内的CDN加速了,目前都只能解析到海外,不但速度慢,还会偶发性无法连接到服务器。因此国内超多网站都受到了影响。现在cdn.jsdelivr.net被墙,国内打不开这导致大部分网站js与css失效,所以要把jsdelivr的js和css替换一下,我选择直接替换到本地。
下面放我改好的文件,替换主题的原文件即可。
把 post.php
文件里的head标签替换为下列代码
need('public/include.php'); ?>
options->JPrismTheme) : ?>
把 page.php
内的head标签修改为下列代码
need('public/include.php'); ?>
options->JPrismTheme) : ?>
把 archive.php
内的head标签修改为下列代码
need('public/include.php'); ?>
还有一个地方是代码高亮的调用,把 functions.php
内的代码高亮的调用修改为下列代码(js已经放在文件里了,直接调用即可)
$JPrismTheme = new Typecho_Widget_Helper_Form_Element_Select(
'JPrismTheme',
array(
'/usr/themes/Joe/assets/css/prism.min.css' => 'prism(默认)',
'/usr/themes/Joe/assets/css/prism-dark.min.css' => 'prism-dark',
'/usr/themes/Joe/assets/css/prism-okaidia.min.css' => 'prism-okaidia',
'/usr/themes/Joe/assets/css/prism-solarizedlight.min.css' => 'prism-solarizedlight',
'/usr/themes/Joe/assets/css/prism-tomorrow.min.css' => 'prism-tomorrow',
'/usr/themes/Joe/assets/css/prism-twilight.min.css' => 'prism-twilight',
'/usr/themes/Joe/assets/css/prism-a11y-dark.min.css' => 'prism-a11y-dark',
'/usr/themes/Joe/assets/css/prism-atom-dark.min.css' => 'prism-atom-dark',
'/usr/themes/Joe/assets/css/prism-base16-ateliersulphurpool.light.min.css' => 'prism-base16-ateliersulphurpool.light',
'/usr/themes/Joe/assets/css/prism-cb.min.css' => 'prism-cb',
'/usr/themes/Joe/assets/css/prism-coldark-cold.min.css' => 'prism-coldark-cold',
'/usr/themes/Joe/assets/css/prism-coldark-dark.min.css' => 'prism-coldark-dark',
'/usr/themes/Joe/assets/css/prism-darcula.min.css' => 'prism-darcula',
'/usr/themes/Joe/assets/css/prism-dracula.min.css' => 'prism-dracula',
'/usr/themes/Joe/assets/css/prism-duotone-dark.min.css' => 'prism-duotone-dark',
'/usr/themes/Joe/assets/css/prism-duotone-earth.min.css' => 'prism-duotone-earth',
'/usr/themes/Joe/assets/css/prism-duotone-forest.min.css' => 'prism-duotone-forest',
'/usr/themes/Joe/assets/css/prism-duotone-light.min.css' => 'prism-duotone-light',
'/usr/themes/Joe/assets/css/prism-duotone-sea.min.css' => 'prism-duotone-sea',
'/usr/themes/Joe/assets/css/prism-duotone-space.min.css' => 'prism-duotone-space',
'/usr/themes/Joe/assets/css/prism-ghcolors.min.css' => 'prism-ghcolors',
'/usr/themes/Joe/assets/css/prism-gruvbox-dark.min.css' => 'prism-gruvbox-dark',
'/usr/themes/Joe/assets/css/prism-hopscotch.min.css' => 'prism-hopscotch',
'/usr/themes/Joe/assets/css/prism-lucario.min.css' => 'prism-lucario',
'/usr/themes/Joe/assets/css/prism-material-dark.min.css' => 'prism-material-dark',
'/usr/themes/Joe/assets/css/prism-material-light.min.css' => 'prism-material-light',
'/usr/themes/Joe/assets/css/prism-material-oceanic.min.css' => 'prism-material-oceanic',
'/usr/themes/Joe/assets/css/prism-night-owl.min.css' => 'prism-night-owl',
'/usr/themes/Joe/assets/css/prism-nord.min.css' => 'prism-nord',
'/usr/themes/Joe/assets/css/prism-pojoaque.min.css' => 'prism-pojoaque',
'/usr/themes/Joe/assets/css/prism-shades-of-purple.min.css' => 'prism-shades-of-purple',
'/usr/themes/Joe/assets/css/prism-synthwave84.min.css' => 'prism-synthwave84',
'/usr/themes/Joe/assets/css/prism-vs.min.css' => 'prism-vs',
'/usr/themes/Joe/assets/css/prism-vsc-dark-plus.min.css' => 'prism-vsc-dark-plus',
'/usr/themes/Joe/assets/css/prism-xonokai.min.css' => 'prism-xonokai',
'/usr/themes/Joe/assets/css/prism-onelight.min.css' => 'prism-onelight',
'/usr/themes/Joe/assets/css/prism-onedark.min.css' => 'prism-onedark',
'/usr/themes/Joe/assets/css/prism-onedark2.min.css' => 'prism-onedark2',
),
'//cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism.min.css',
'选择一款您喜欢的代码高亮样式',
'介绍:用于修改代码块的高亮风格
其他:如果您有其他样式,可通过源代码修改此项,引入您的自定义样式链接'
);
$JPrismTheme->setAttribute('class', 'joe_content joe_post');
$form->addInput($JPrismTheme->multiMode());
这里的Joe是我的主题目录,如果你的不是就改成你的目录名。
写的比较匆忙,先备份主题再测试,有问题及时反馈。
本文来源于星泽V社,未经允许禁止转载,原文链接:https://cloud.tencent.com/developer/article/2005916
本文共 332 个字数,平均阅读时长 ≈ 1分钟