嵌入用于将社交媒体帖子等外部内容直接放入网页,在提升用户互动的同时,不牺牲站点性能与安全性。
Cloudflare Zaraz 为嵌入引入了服务端渲染,避免使用第三方 JavaScript,从而提升安全性、隐私与页面速度。该方法在服务端处理内容,无需用户浏览器与第三方服务器直接通信。
要向网站添加嵌入:
-
在 Cloudflare 仪表板中,前往 **Tag Setup(标签设置)**页面。
Go to Tag setup ↗ -
前往 Tools Configuration(工具配置)。
-
选择 Add new tool(添加新工具),并在 Cloudflare Zaraz 仪表板中激活所需工具。
-
在 HTML 中添加占位符,并指定必要属性。通用嵌入的代码片段如下:
<componentName-embedName attribute="value"></componentName-embedName>将 componentName、embedName 和 attribute="value" 替换为具体 Managed Component 的要求。Zaraz 会自动检测占位符,并以安全、高效的方式将其替换为内容。
<twitter-post tweet-id="12345"></twitter-post>将 tweet-id 替换为要嵌入内容的实际推文 ID。
<instagram-post post-url="https://www.instagram.com/p/ABC/" captions="true"></instagram-post>将 post-url 替换为要嵌入内容的实际 URL。若要包含帖子说明,请将 captions 属性设为 true。