
內容簡介
使用 Pantheon 的 Gist Block 外掛,您可以在 Gutenberg 文章中嵌入 GitHub Gists。只需添加「GitHub Gist」區塊,貼上 Gist 的 URL,即可看到它變成美妙的預覽。
想知道區塊是如何運作的嗎?這是一個很好的探索機會。具體而言,請檢查以下實現細節:
區塊 UI 註冊在 blocks/github-gist/index.js 中。當在 Gutenberg 中預覽區塊時,使用自定義代碼生成嵌入。
後備 HTML 內容實際上是存儲在文章內容中的內容。
使用動態渲染回調將區塊轉換為 GitHub 的標準 Gist 嵌入代碼。
閱讀「如何將短碼轉換為 Gutenberg 區塊」以獲得有關該插件的更詳細解釋。
有任何問題需要澄清嗎?請查看 GitHub 上的該項目,了解任何問題,反饋,建議或拉取請求。
外掛標籤
開發者團隊
原文外掛簡介
The Gist Block by Pantheon makes it possible to embed GitHub Gists in your Gutenberg posts. Simply add the “GitHub Gist” block, paste the URL to your Gist, and see it transform to a wonderful preview.
Curious as to how blocks work? This is a great one to explore. Specifically, check out these implementation details:
Block UI is registered in blocks/github-gist/index.js. When the block is previewed in Gutenberg, custom code is used to generate the embed.
Fallback HTML content is what’s actually stored in the post content.
A dynamic render callback is used to transform the block to GitHub’s standard Gist embed code.
Read “How to Convert a Shortcode to a Gutenberg Block” for a more detailed explanation of the plugin.
Something we can clarify? Check out the project on GitHub for any questions, feedback, suggestions, or pull requests.
