RSS 订阅源自动发现可能会错过特定主题的订阅源

你好 Arya,

是的,这确实是 Discourse 当前处理特定于主题的 RSS 源的方式所导致的结果,而不是你的源阅读器中的错误。根本原因在于 Discourse 会向主题/类别 RSS 源的 <a> 元素添加 rel="nofollow"。许多源阅读器会忽略带有 nofollow 的链接,这会阻止自动发现,即使源本身是有效的并且直接访问时可以正常工作。

一个实用的解决方法是使用一个 主题组件 (Theme Component) 来添加不带 nofollow 的特定于主题的 RSS 链接。这是一个简单的示例:

<!-- 添加不带 nofollow 的特定于主题的 RSS 链接 -->
<script type="text/discourse-plugin" version="0.8">
  api.onPageChange((url, title) => {
    document.querySelectorAll('link.custom-rss').forEach(e => e.remove());
    document.querySelectorAll('link[title^="RSS feed of"]').forEach(link => {
      const newLink = document.createElement('link');
      newLink.rel = "alternate";
      newLink.type = "application/rss+xml";
      newLink.href = link.href;
      newLink.title = link.title;
      newLink.classList.add('custom-rss');
      document.head.appendChild(newLink);
    });
  });
</script>

这将扫描所有主题/类别 RSS 链接,并将新的不带 nofollow 的 <a> 元素注入到 <head> 中。

源阅读器现在应该可以自动检测特定于主题的源了!

或者,对于更简单的方法,你可以直接与用户共享源 URL,例如 https://community.nlnetlabs.nl/c/cascade/10.rss。

此方法避免了修改 Discourse 的核心部分,并且可以在更新后继续使用。希望这能帮助源自动发现按预期工作!

干杯!

1 个赞