惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
I
InfoQ
人人都是产品经理
人人都是产品经理
博客园 - 三生石上(FineUI控件)
爱范儿
爱范儿
Hugging Face - Blog
Hugging Face - Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
SegmentFault 最新的问题
美团技术团队
小众软件
小众软件
Blog — PlanetScale
Blog — PlanetScale
Jina AI
Jina AI
aimingoo的专栏
aimingoo的专栏
H
Help Net Security
Last Week in AI
Last Week in AI
博客园_首页
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
L
LangChain Blog
云风的 BLOG
云风的 BLOG
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
G
Google Developers Blog
博客园 - 叶小钗
博客园 - Franky

szhshp 的第三边境研究所

假设, AI 把我代替的那一刻真的到来 | szhshp 的第三边境研究所 小傻瓜都能懂的 AstrBot QQ 机器人集成 MCP 功能实战指南 | szhshp 的第三边境研究所 《智人之上: 从石器时代到 AI 时代的信息网络简史》阅读笔记 | szhshp 的第三边境研究所 iPadOS 26 无法设置空间场景图片壁纸的解决方法 | szhshp 的第三边境研究所 《一路云海》(终) | szhshp 的第三边境研究所 《一路云海》(四): 如何不按套路旅行 | szhshp 的第三边境研究所 《一路云海》(三): In Ya Mellow Tone | szhshp 的第三边境研究所 《一路云海》(二): 关西世博参观纪实 | szhshp 的第三边境研究所 《一路云海》(一): 新的征程 | szhshp 的第三边境研究所 2025 大阪世博会 [ 3 天前-先到先得 ] 阶段 场馆预约必中独家攻略 | szhshp 的第三边境研究所 Hackathon 随想 | szhshp 的第三边境研究所 一杯双皮奶 | szhshp 的第三边境研究所 Armbian + CasaOS + NAS 配置指南 | szhshp 的第三边境研究所 Docker 构建镜像报错: error getting credentials - err: exit status 1, out: `` | szhshp 的第三边境研究所 Disqus RIP! 论过高的维护成本如何治疗固执的坏习惯 | szhshp 的第三边境研究所 炸弹猫桌游变体规则 | szhshp 的第三边境研究所 《小岛经济学》阅读笔记 | szhshp 的第三边境研究所 《金钱心理学》阅读笔记 | szhshp 的第三边境研究所 为知笔记 RIP: 迁移剩余的笔记 | szhshp 的第三边境研究所 2025 博客第十年展望 - 再见我的过去 | szhshp 的第三边境研究所 我在独立游戏里面致敬的作品 | szhshp 的第三边境研究所 《How to make thing faster》阅读笔记 | szhshp 的第三边境研究所 《The Art of Clean Code》阅读笔记 | szhshp 的第三边境研究所 《Clean Architecture: A Craftsman Guide to Software Structure and Design》阅读笔记 | szhshp 的第三边境研究所 《How AI Works》阅读笔记 | szhshp 的第三边境研究所 游戏策划废案 - Project Uranus | szhshp 的第三边境研究所 游戏策划废案 - Project X | szhshp 的第三边境研究所 人生第一款独立游戏开发复盘 | szhshp 的第三边境研究所 Trap of Life | szhshp 的第三边境研究所 如果我用手搓了个暗物质雏形 | szhshp 的第三边境研究所
全站点升级 - Project Titan | szhshp 的第三边境研究所
2020-07-19 · via szhshp 的第三边境研究所

Meta

目录

Project Titan

全站点升级

这个网站一开始通过 Jekyll x JQuery x Bootstrap 构建, 由我一人设计编码并开源: szhshp/JekyllTheme-ProjectGaia.

早先设计灵感参考了 Bootstrap x Stylish Portfolio x Next 等主题.

在 2020 年 5 月, 我就有了全站重写的想法, 最终选择了 NextJS 引擎

花费 48 天, 全部站点用全新的技术重构, 当前技术栈: NextJS x React x MaterialUI

同时因为难得有这一次重构的机会, 我将依赖全部集成到了本体架构中

Github: szhshp/NextJS-BlogTemplate-ProjectTitan

Misc/Troubleshooting

Framework-NextJS

(TODO)

Components

如果你比较懒, 可以直接用这个库: disqus/disqus-react

或者自定义一些设置, 这里是一个例子:

import React, {useEffect} from 'react'

const Comments = ({fullUrl, id}) => {
  useEffect(() => {
    const DISQUS_SCRIPT = 'disq_script'
    const sd = document.getElementById(DISQUS_SCRIPT)
    if (!sd) {
      var disqus_config = function() {
        this.page.url = fullUrl
        this.page.identifier = id
      }

      const d = document
      const s = d.createElement('script')
      s.src = 'https://MYDISQUS.disqus.com/embed.js' // REPLACE THIS LINE WITH YOUR DISQUS LINE
      s.id = DISQUS_SCRIPT
      s.async = true
      s.setAttribute('data-timestamp', +new Date())

      d.body.appendChild(s)
    } else {
      window.DISQUS.reset({
        reload: true,
        config: disqus_config,
      })
    }
  }, [])
  return <div id="disqus_thread"></div>
}

export default Comments

或者使用这种方法:

import React from 'react'

const Comments = ({fullUrl, id}) => {
  const html = `
  <div id="disqus_thread"></div>
  <script>
  var disqus_config = function () {
  this.page.url = '${fullUrl}';
  this.page.identifier = '${id}';
  };
  (function() {
  var d = document, s = d.createElement('script');
  s.src = 'https://MYDISQUS.disqus.com/embed.js';
  s.setAttribute('data-timestamp', +new Date());
  (d.head || d.body).appendChild(s);
  })();
  </script>
  `

  return <div dangerouslySetInnerHTML={{ __html: html}} />
}

export default Comments

类似问题:

  1. We were unable to load Disqus
  2. Disqus 无法加载。如果您是管理员,请参阅故障排除指南
  3. There was a problem with the Disqus configuration

Disqus 无法加载, 一般都是因为 identifier 设置错了或者 config 设置方式不对

An example in Typescript:

  const DisqusCommentBox = (props): JSX.Element => {
  const { identifier } = props;

  useEffect(() => {
    if (debug) {
      return;
    }

    /**
     * The config for native disqus
     * @see https://help.disqus.com/en/articles/1717084-javascript-configuration-variables
     */
    const nativeDisqusConfigScript = document.createElement("script");
    nativeDisqusConfigScript.innerHTML = `
      window.disqus_config = function () {
        this.page.url = window.location.href;
        this.page.identifier = '${identifier}';
        this.page.title  = document.title;
      };
    `;
    document.body.appendChild(nativeDisqusConfigScript);

    const s = document.createElement("script");

    /* trigger an error in debug mode */
    s.src = `http://${username}.disqus.com/embed.js`;
    s.async = true;
    s.setAttribute("data-timestamp", String(+new Date()));
    document.body.appendChild(s);
  }, []);

  return <div id="disqus_thread" />;
};

Reference