跳到主要内容

Enable X (Twitter) Cards in Docusaurus

· 阅读需 3 分钟
liruqi
Founder of Chinapedia

To enable X (formerly Twitter) cards in Docusaurus, you primarily configure the metadata within your docusaurus.config.js (or .ts) file. Docusaurus uses these settings to populate the <head> tags that social media platforms crawl to generate preview cards. [1, 2, 3]

1. Global Configuration

Open your docusaurus.config.js and add or update the themeConfig object. This sets the default card behavior for your entire site. [2, 4, 5]

module.exports = {
// ... other config
themeConfig: {
metadata: [
{name: 'twitter:card', content: 'summary_large_image'},
{name: 'twitter:site', content: '@YourTwitterHandle'},
{name: 'twitter:creator', content: '@YourTwitterHandle'},
],
image: 'img/docusaurus-social-card.jpg', // Path to your default social card image
},
};

2. Individual Page Metadata

If you want a specific blog post or documentation page to have its own unique X card image, you can override the global settings using Front Matter at the top of your Markdown file. [1, 6]

---
title: My Awesome Page
description: A brief summary of this page for the X card.
image: /img/unique-page-card.png
---
# Your Content Here

3. Key Metadata Tags

Ensure these specific tags are present (either globally or per page) for the best results:

  • twitter:card: Set to summary (small image) or summary_large_image (full-width image).
  • twitter:image: The URL to the image. Docusaurus typically handles this via the image field in your config or front matter.
  • og:title & og:description: X often falls back to Open Graph (OG) tags if specific Twitter tags are missing. [7, 8]

4. Testing Your Card

After deploying your site, you can verify how the card looks using the X Post Validator (note: X has moved some validation features directly into the post composer preview, but third-party tools like OpenGraph.xyz are also excellent for testing). [9, 10, 11]

Would you like to know how to automate social card generation for every page instead of creating images manually?

[11]: https://www.tweetarchivist.com/twitter-card-validator-guide#:~:text=This%20process%20usually%20completes%20within%20a%20few,%28%20X%20%28formerly%20Twitter%29%20%27s%20feed.)

Enabling OpenClaw Control UI for LAN Access

· 阅读需 2 分钟
liruqi
Founder of Chinapedia

Accessing the OpenClaw Control UI from other devices on your local network requires a few manual configuration changes to the gateway settings.

By default, OpenClaw might be restricted to local access for security. To enable LAN access (e.g., accessing from your phone or another laptop at http://192.168.1.x:18789), you need to update your configuration file.

Configuration Changes

You need to modify the gateway section of your OpenClaw configuration. Specifically, ensure that bind is set to lan and that the controlUi section includes the correct allowedOrigins.

The final configuration should look like this:

{
"gateway": {
"port": 18789,
"mode": "local",
"bind": "lan",
"controlUi": {
"allowedOrigins": [
"http://localhost:18789",
"http://127.0.0.1:18789",
"http://192.168.1.165:18789"
],
"allowInsecureAuth": true,
"dangerouslyDisableDeviceAuth": true
}
}
}

Key Settings Explained

  • bind: "lan": Sets the gateway to listen on all local network interfaces instead of just the loopback interface.
  • allowedOrigins: You must explicitly list the IP address or hostname of your server here. Browsers enforce CORS, and the Control UI won't be able to talk to the gateway if its origin isn't allowed.
  • allowInsecureAuth: Set this to true if you are not using HTTPS on your local network (common for internal home labs).
  • dangerouslyDisableDeviceAuth: This skips device-specific authentication checks, making it easier to connect from multiple devices on the LAN. Use with caution in public networks.

Once you have applied these changes, restart your OpenClaw service openclaw gateway restart for the new settings to take effect.

开启 OpenClaw 控制界面的局域网访问

· 阅读需 2 分钟
liruqi
Founder of Chinapedia

如果您在家庭服务器或专用机器上运行 OpenClaw,您可能希望从局域网(LAN)中的其他设备(例如手机或其他笔记本电脑)访问其控制界面。这需要对 gateway 部分进行一些配置调整。

默认情况下,出于安全考虑,OpenClaw 可能被限制为仅供本地访问。要开启局域网访问(例如通过 http://192.168.1.x:18789 访问),您需要更新配置文件。

配置更改

您需要修改 OpenClaw 配置中的 gateway 部分。具体请确保将 bind 设置为 lan,并确保 controlUi 部分包含正确的 allowedOrigins

最终配置应如下所示:

{
"gateway": {
"port": 18789,
"mode": "local",
"bind": "lan",
"controlUi": {
"allowedOrigins": [
"http://localhost:18789",
"http://127.0.0.1:18789",
"http://192.168.1.165:18789"
],
"allowInsecureAuth": true,
"dangerouslyDisableDeviceAuth": true
}
}
}

关键设置说明

  • bind: "lan":设置网关在所有本地网络接口上监听,而不仅限于回环接口 (127.0.0.1)。
  • allowedOrigins:您必须在此处显式列出服务器的 IP 地址或主机名。浏览器强制执行 CORS 策略,如果其来源未被允许,控制界面将无法与网关通信。
  • allowInsecureAuth:如果您在局域网中不使用 HTTPS(家庭实验室常用),请将其设置为 true
  • dangerouslyDisableDeviceAuth:这会跳过特定设备的身份验证检查,使从局域网上的多个设备连接更加容易。在公共网络中请谨慎使用。

完成这些更改后,请重启您的 OpenClaw 服务:执行 openclaw gateway restart 以使新设置生效。

Welcome

· 阅读需 1 分钟
liruqi
Founder of Chinapedia

大家好,欢迎来到中国百科(Chinapedia)。

在这里,我们共同致力于看中国、看世界。

我们的目标

中国百科的使命是完善中文 UGC(用户生成内容) 与 AIGC(人工智能生成内容)。我们深感现有的中文维基百科虽然规模宏大,但其审核机制过于严苛,且长期受特定群体把持,在许多内容的处理上带有明显的政治倾向。

我们在这里拥抱 AI,拥抱评论形式的原创内容。我们的目标是构建一个更真实、更具活力的中文知识家园。

加入我们

我们欢迎有各行业从业经验的人士加入我们,从事分类内容管理与审核。您的加入将是完善中文知识图谱的关键力量。

Long Blog Post

· 阅读需 3 分钟
Yangshun Tay
Ex-Meta Staff Engineer, Co-founder GreatFrontEnd

This is the summary of a very long blog post,

Use a <!-- truncate --> comment to limit blog post size in the list view.