add-x-tweet
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAdd X Tweet Testimonial
添加X推文推荐语
Add social proof tweets to the homepage testimonial grid.
为主页推荐语网格添加社交证明类推文。
When to use
使用场景
- User provides one or more URLs
https://x.com/.../status/... - User asks to replace, prioritize, or reorder testimonials
- User says "add tweet", "new testimonial", or similar
- 用户提供一个或多个 格式的URL
https://x.com/.../status/... - 用户要求替换、优先排序或重新排列推荐语
- 用户提及“添加推文”“新推荐语”或类似需求
Workflow
操作流程
1. Fetch tweet metadata
1. 获取推文元数据
Run the fetch script from the repo root (requires network):
bash
node .agents/skills/add-x-tweet/scripts/fetch-tweet.mjs "https://x.com/user/status/123..."For multiple URLs, pass each URL or run once per URL.
The script prints JSON:
json
{
"id": "123...",
"url": "https://x.com/user/status/123...",
"author": { "name": "...", "handle": "@user", "avatar": "https://pbs.twimg.com/...", "verified": true },
"content": "tweet text without @uixmat prefix"
}Fallback: If the script fails, use Twitter oEmbed:
bash
curl -sL "https://publish.twitter.com/oembed?url=TWEET_URL&omit_script=1"Parse and HTML for text. Avatar still needs fxtwitter or manual profile image URL.
author_name<p>从仓库根目录运行获取脚本(需要网络连接):
bash
node .agents/skills/add-x-tweet/scripts/fetch-tweet.mjs "https://x.com/user/status/123..."若有多个URL,可逐个传入或多次运行脚本。
脚本会输出JSON格式数据:
json
{
"id": "123...",
"url": "https://x.com/user/status/123...",
"author": { "name": "...", "handle": "@user", "avatar": "https://pbs.twimg.com/...", "verified": true },
"content": "去除@uixmat前缀后的推文文本"
}备用方案: 若脚本运行失败,使用Twitter oEmbed:
bash
curl -sL "https://publish.twitter.com/oembed?url=TWEET_URL&omit_script=1"解析字段和HTML中的标签获取文本内容。头像仍需通过fxtwitter或手动获取个人资料图片URL。
author_name<p>2. Edit apps/web/lib/testimonials.ts
apps/web/lib/testimonials.ts2. 编辑 apps/web/lib/testimonials.ts
文件
apps/web/lib/testimonials.ts- Use status id as (numeric string from URL)
id - Set to the canonical tweet URL (no query params)
url - Run avatar through (upgrades
twitterAvatarUrl()→_200x200)_400x400 - Strip leading from content; trim whitespace
@uixmat - Shorten very long tweets if they include trailing promo links (keep the praise, drop link-only tails)
- 使用状态ID作为(从URL中提取的数字字符串)
id - 将设置为标准推文URL(不带查询参数)
url - 将头像URL传入函数(将
twitterAvatarUrl()升级为_200x200)_400x400 - 移除内容开头的并修剪空白字符
@uixmat - 若推文过长且包含末尾推广链接,可缩短内容(保留好评部分,移除仅含链接的尾部)
3. Ordering rules
3. 排序规则
Masonry uses CSS columns (top-to-bottom per column). On , indices 0–2 = column 1 top 3, 3–5 = column 2 top 3, 6–8 = column 3 top 3.
lg- Prioritize when asked: place in the next open slot among indices 0–8 without duplicating ids
- Replace when asked: remove the old entry (match by handle or old id) before adding the new one
- Set from script output (
author.verifiedvia FxTwitter)author.verification.verified
瀑布流布局使用CSS列(每列从上到下排列)。在屏幕尺寸下,索引0–2对应第1列的前3个位置,3–5对应第2列的前3个位置,6–8对应第3列的前3个位置。
lg- 若用户要求优先排序:将新条目放在索引0–8的下一个空位,且不重复ID
- 若用户要求替换:先移除旧条目(通过用户名或旧ID匹配),再添加新条目
- 根据脚本输出设置字段(通过FxTwitter获取
author.verified值)author.verification.verified
4. Collapsed grid
4. 折叠网格
The homepage shows (6) cards before See more. No change needed when adding tweets unless the user asks to change visible rows.
testimonialCollapsedCount主页在显示(默认6个)卡片后会显示“查看更多”按钮。添加推文时无需修改此设置,除非用户要求更改可见行数。
testimonialCollapsedCount5. Verify
5. 验证
bash
cd apps/web && npx tsc --noEmit -p tsconfig.jsonOpen homepage — grid is 3 columns, bottom fade + See more expands max-height.
bash
cd apps/web && npx tsc --noEmit -p tsconfig.json打开主页确认:网格为3列布局,底部渐变效果 + “查看更多”按钮可展开最大高度。
Data source
数据源
Primary: FxTwitter API — returns author name, screen_name, avatar_url, and text.
https://api.fxtwitter.com/{user}/status/{id}Do not commit API keys; the public endpoint is used by the script only at add-tweet time.
主要数据源:FxTwitter API — 返回作者姓名、用户名、头像URL和文本内容。
https://api.fxtwitter.com/{user}/status/{id}请勿提交API密钥;脚本仅在添加推文时使用公开端点。
Example entry
示例条目
ts
{
id: "2056717453816729751",
url: "https://x.com/jordienr/status/2056717453816729751",
author: {
name: "jordi",
handle: "@jordienr",
avatar: twitterAvatarUrl(
"https://pbs.twimg.com/profile_images/2053541405121769475/TUDez6zL_200x200.jpg"
),
verified: true,
},
content: "bklit saved my marriage",
},ts
{
id: "2056717453816729751",
url: "https://x.com/jordienr/status/2056717453816729751",
author: {
name: "jordi",
handle: "@jordienr",
avatar: twitterAvatarUrl(
"https://pbs.twimg.com/profile_images/2053541405121769475/TUDez6zL_200x200.jpg"
),
verified: true,
},
content: "bklit saved my marriage",
},