Skip to main content

Module share_meta

Module share_meta 

Source
Expand description

分享元信息(description / Open Graph / Twitter 卡片)。 分享元信息:description、Open Graph 与 Twitter 卡片。

只有服务端渲染的 HTML 会被社交平台读取,但客户端导航后挂载的标签也要与直达页面一致。 站点信息由中间件放进请求扩展(crate::models::share::ShareContext), 再由 provide_share_context 在 App 根部经 SharedValue 序列化,浏览器水合时读回。 标签顺序固定,以便水合按顺序对齐。

组件只写 <head>、没有可见内容,不进组件图鉴,故为 pub(crate)。

Structs§

PostShareMetaProps 🔒
Props for the PostShareMeta component.
ShareTagsProps 🔒
Props for the ShareTags component.
SiteShareMetaProps 🔒
Props for the SiteShareMeta component.

Functions§

PostShareMeta 🔒
文章页:标题、摘要、文章分享图与发布时间、标签。
ShareTags 🔒
一组分享标签:description、Open Graph 与 Twitter 卡片(顺序固定,水合按顺序对齐)。
SiteShareMeta 🔒
除文章页外的前台页面:站点描述与站点分享图。
provide_share_context 🔒
应用根组件调用一次:服务端从请求扩展读取分享上下文并序列化进页面,浏览器水合时读回同一份值。 必须在水合期间创建(App 根部):水合结束后才创建的 SharedValue 会在浏览器端重新求值,只能得到空值。
share_context_from_request 🔒
use_share_context 🔒
读取分享上下文;没有上下文时(组件单测)返回空值。