Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)8.1k · #12580

wb-preview-url-modifier

Skill này làm gì

Skill này cho AI của bạn biết cách thêm tham số bổ sung vào liên kết xem trước của các trang Website Builder trong Webiny. Dành cho lập trình viên cần liên kết xem trước mang token, tenant ID hoặc cờ.

Khi nào nên dùng

  • ✓Khi liên kết xem trước phải chứa token có chữ ký hoặc mã tenant.
  • ✓Khi bạn muốn giá trị feature flag được truyền vào URL xem trước trực tiếp.
  • ✓Khi liên kết xem trước cần dữ liệu lấy từ dịch vụ khác trước khi mở.

Liên kết skill

https://github.com/webiny/webiny-js/blob/next/skills/user-skills/admin/website-builder/wb-preview-url-modifier/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/webiny/webiny-js/blob/next/skills/user-skills/admin/website-builder/wb-preview-url-modifier/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Làm mọi liên kết xem trước của Website Builder có chứa token có chữ ký lấy từ dịch vụ xem trước của chúng tôi.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill giải thích cách viết một class nhỏ thay đổi địa chỉ xem trước trước khi mở, rồi đăng ký class đó trong dự án. Class có thể chờ giá trị từ xa khi cần.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Website Builder: Preview URL Modifier

TL;DR

PreviewUrlModifier is a DI extension point that lets project developers inject custom query parameters into all Website Builder live preview URLs. Register one implementation; it receives the full URL object and can mutate it however it needs — including async operations like fetching a signed token from a remote API.

Implement the Modifier

Import from webiny/admin/website-builder. The single required method is modify(url: URL): Promise<void> — mutate url.searchParams in place, mark the method async when you need to fetch remote values.

import { PreviewUrlModifier } from "webiny/admin/website-builder";

class MyPreviewUrlModifier implements PreviewUrlModifier.Interface {
  async modify(url: URL) {
    url.searchParams.set("my-param", "my-value");
  }
}

export default PreviewUrlModifier.createImplementation({
  implementation: MyPreviewUrlModifier,
  dependencies: []
});

Async example — fetching a signed token:

class SignedTokenModifier implements PreviewUrlModifier.Interface {
  async modify(url: URL) {
    const token = await fetch("/api/preview-token").then(r => r.text());
    url.searchParams.set("token", token);
  }
}

export default PreviewUrlModifier.createImplementation({
  implementation: SignedTokenModifier,
  dependencies: []
});

Register the Feature

// extensions/previewUrlModifier/index.tsx
import React from "react";
import { createFeature, RegisterFeature } from "webiny/admin";
import MyPreviewUrlModifier from "./MyPreviewUrlModifier.js";

const PreviewUrlModifierFeature = createFeature({
  name: "MyApp/PreviewUrlModifier",
  register(container) {
    container.register(MyPreviewUrlModifier);
  }
});

export default () => <RegisterFeature feature={PreviewUrlModifierFeature} />;
// webiny.config.tsx
<Admin.Extension src={"@/extensions/previewUrlModifier/index.tsx"} />

Where It Applies

Surface Description
Editor iframe The live-editing iframe in the page editor
Address bar link The "copy preview link" button in the editor toolbar
Pages list Preview icon links in the pages list table

Constraints

  • One modifier per project. Only the first registered implementation is used.
  • Mutate in place. Return value is ignored; mutate the URL object directly.
  • No wb.* collisions. Params prefixed wb. are reserved for internal use.

Related Skills

  • wb-custom-page-types -- registering custom page types via PageType abstraction
  • wb-page-settings -- extending page settings groups and fields
Câu hỏi thường gặp

Thay đổi có thể phụ thuộc vào dữ liệu từ xa không?

Có. Modifier có thể bất đồng bộ, ví dụ để lấy token có chữ ký từ một API.

Nó được đăng ký ở đâu?

Nó được nối qua một tính năng và thêm vào file cấu hình webiny của dự án.

Nó có thay đổi trang đã xuất bản không?

Skill chỉ liên quan đến liên kết xem trước trực tiếp, không liên quan đến trang đã xuất bản.

Chi tiết

Mô tả gốc của tác giả

Covers the PreviewUrlModifier extension point in Website Builder. Use when a user wants to inject custom query parameters into live preview URLs — e.g. signed tokens, tenant identifiers, feature flags — from their Webiny project. Handles the full registration pattern: implementing the interface, wiring via createFeature + RegisterFeature, and registering via webiny.config.tsx. Supports async modifier methods (e.g. remote token fetch).

repo: webiny/webiny-js

Độ phổ biến

Sao GitHub
8.1k
Vị trí xếp hạng
#12580
Giấy phép
—
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự