Ghost添加阅读进度条

分享
Ghost添加阅读进度条

进度条其实是一个不是很必要的功能,不过,有这个功能,在看文章的时候就能大概知道阅读的进度,总体上如果不是太耀眼,还是挺好的一个功能。要实现这个功能,只需要在Ghost后台的Code injection里面添加两段代码就可以了。

效果参考

Scroll progress widget
In today’s fast-paced digital world, the boundaries between technology and creativity are increasingly blurred. Innovations in augmented reality (AR), blockchain, cloud computing, coding, design, gadgets, graphics, UI/UX, and virtual reality (VR) are reshaping industries and creating new possibilities. This essay explores the dynamic interplay between these elements and their

代码

函数

在Site footer添加如下代码:

<progress value="0" max="100" data-progress-bar></progress>
<script>
  function getScrollPercent() {
    const h = document.documentElement, 
          b = document.body,
          st = 'scrollTop',
          sh = 'scrollHeight';
    return Math.round((h[st]||b[st]) / ((h[sh]||b[sh]) - h.clientHeight) * 100);
  }
  const progressBar = document.querySelector('[data-progress-bar]');
  if (progressBar) {
    progressBar.setAttribute('value', getScrollPercent());
    window.addEventListener('scroll', () => {
      progressBar.setAttribute('value', getScrollPercent());
    });
  }
</script> 

样式

在Site header添加如下代码:

阅读更多

更好的字幕翻译工具

更好的字幕翻译工具

如果你还在找一个更好的字幕翻译工具,那么就是是“沉浸式翻译”这个浏览器插件把,免费版本可以使用微软翻译、硅基流动翻译、GlM-4 Flash和Babel lite。 我测试了一下《挽救计划》的英文字幕,翻译成中文。这部电影的字幕其实难度还是挺大的,不过就我测试了硅基流动翻译、GlM-4 Flash和Babel lite 3个模型的翻译效果,这里推荐Babel lite模型。原因如下: 字幕里面有一个断句的 文本,Babel lite能准确翻译出原文表达的意思: 00:09:4900:09:52Over the next 30 years, the Earth could在未来 30 年,地球可能会 00:09:5200:09:55cool maybe 10凉爽,也许 10

By typenode
给网站添加view-transition动画

给网站添加view-transition动画

view-transition是一个很专业的功能,可以通过CSS去实现网页动画,在跨网页浏览上启用view-transition,无需多余配置即可获得一个优雅的网站页面切换效果。 适用于多页面应用的跨文档视图过渡 | View Transitions | Chrome for Developers开始在您的多页应用 (MPA) 中使用跨文档视图过渡。Chrome for DevelopersX demo: HomecamelCase 配置 在Code injection里面添加如下代码即可: <style> @view-transition { navigation: auto; } ::view-transition-group(root){ animation-duration:600ms } </style>

By typenode
Fix ActivityPub Webhook Error

Fix ActivityPub Webhook Error

之前的Ghost托管在PikaPods上面,其实相当于是Managed Ghost,所以你不需要去操心服务器的配置。最近换了服务商,那么情况就不一样了,遇到的所有问题都需要自己去处理,其中一个就是ActivityPub无法正常使用。 错误排查 查看log后发现报错:No Webhook Secret Found。 原因分析 * /.ghost/activitypub/* * /.well-known/webfinger * /.well-known/nodeinfo 上面三个ActivityPub资源配置错误,并未通过https反对带至ap.ghost.org。 处理办法 将需要反代的路径添加至nginx配置文件即可: location ~ /.ghost/activitypub/* { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_se

By typenode