Add dark mode to your website using DarkReader. This is a simple way to add dark mode to your website.
GitHub: https://github.com/darkreader/darkreader
Add code below to _includes/head.html
in your Jekyll project.
{% if jekyll.environment == 'production' -%}
<!-- dark theme using DarkReader -->
<script src="//unpkg.com/darkreader@4.9.40/darkreader.js"></script>
<script type="text/javascript">
DarkReader.setFetchMethod(window.fetch); // Fix to remedy CORS errors in chrome console
//DarkReader.enable();
DarkReader.auto( {brightness: 100, contrast: 90, sepia: 10} );
</script>
{%- endif %}
Reference: reference the implementation from link
文章作者: Alan Zeng
原始链接: https://alanzeng.com/blogs/317/
版权说明:本博客所有文章除特别声明外,均采用BY-NC-SA 4.0许可协议 。获得许可后,要求转载时注明文章出处和网站链接,谢谢!
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有