betterembed/neos-betterembed

BetterEmbed集成于Neos CMS

2.0.1 2023-07-02 13:39 UTC

This package is auto-updated.

Last update: 2024-09-07 23:46:39 UTC


README

Latest stable version Total downloads License

BetterEmbed集成于Neos CMS

BetterEmbed是一个免费服务,可以轻松集成Twitter帖子、博客帖子或其他任何远程内容。

注意:由于GDPR同意访问网关,并非每个URL都会正常工作。例如,Facebook和Instagram存在已知问题。

BetterEmbed的好处

  • 轻松集成外部内容
  • 通过阻止不想要的跟踪Cookie(GDPR)来提高隐私性
  • 通过不加载外部JavaScript和CSS资源来提高页面速度

如果您想了解更多信息,请访问https://betterembed.com以查看完整功能列表和获取更多项目信息。

安装

将依赖项添加到您的网站包中,如下所示

composer require --no-update betterembed/neos-betterembed

然后在您的项目根目录中运行composer update

依赖项

此包目前仅需要Neos >= 8guzzlehttp/guzzle

使用方法

BetterEmbed content element

BetterEmbed Placeholder

示例

网站示例

BetterEmbed example blog post

API结果
{
    "url": "https://www.theverge.com/2020/3/23/21175407/remote-work-working-from-home-guide-how-to-tips-video-conference-calls-laptops-zoom-slack",
    "itemType": "The Verge",
    "title": "The Verge Guide to Working at Home",
    "body": "Tips and tricks on being a remote worker",
    "thumbnailUrl": "https://cdn.vox-cdn.com/thumbor/NdRt13PSWplEE-lZkxFEPyc4a8U=/0x146:2040x1214/fit-in/1200x630/cdn.vox-cdn.com/uploads/chorus_asset/file/19822359/acastro_200319_3941_wfhGuide_0003.jpg",
    "authorName": "Barbara Krasnoff",
    "publishedAt": "2020-03-23T08:00:00-04:00"
}

YouTube示例

BetterEmbed example Youtube 1 BetterEmbed example Youtube 2 BetterEmbed example Youtube 3

API结果
{
    "embedHtml": "<iframe width=\"480\" height=\"270\" src=\"https://www.youtube.com/embed/-ZHY85m63k0?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>",
    "url": "https://www.youtube.com/watch?v=-ZHY85m63k0",
    "itemType": "YouTube",
    "title": "Neos Con 2019 Teaser Trailer | Neos Conference",
    "body": "Only a few weeks and tickets left till the Neos Con 2019 in Dresden from 10th to 11th May. Be sure to save your spot: https://www.eventbrite.de/e/neos-confer...",
    "thumbnailUrl": "https://i.ytimg.com/vi/-ZHY85m63k0/hqdefault.jpg",
    "authorName": "Neos CMS",
    "authorUrl": "https://www.youtube.com/channel/UCQndryIh2s9i3htDrpb6tiw",
    "publishedAt": "2019-03-29T00:00:00+00:00"
}

Twitter示例

BetterEmbed example Twitter 1 BetterEmbed example Twitter 2 BetterEmbed example Twitter 3

{
    "embedHtml": "<blockquote class=\"twitter-tweet\"><p lang=\"en\" dir=\"ltr\">What a blast! ☺️ Two days full of exciting talks, conversations, networking and way more! Thank you all for being part of it! We hope to see you all again soon! 🥰 <a href=\"https://twitter.com/hashtag/neoscon?src=hash&amp;ref_src=twsrc%5Etfw\">#neoscon</a> <a href=\"https://twitter.com/hashtag/neos?src=hash&amp;ref_src=twsrc%5Etfw\">#neos</a> <a href=\"https://twitter.com/hashtag/community?src=hash&amp;ref_src=twsrc%5Etfw\">#community</a> <a href=\"https://#/nSaZCU2bba\">pic.twitter.com/nSaZCU2bba</a></p>&mdash; The Neos Project (@neoscms) <a href=\"https://twitter.com/neoscms/status/1127605365019947008?ref_src=twsrc%5Etfw\">May 12, 2019</a></blockquote>\n<script async src=\"https://platform.twitter.com/widgets.js\" charset=\"utf-8\"></script>",
    "url": "https://twitter.com/neoscms/status/1127605365019947008",
    "itemType": "Twitter",
    "title": "The Neos Project on Twitter",
    "body": "“What a blast! ☺️ Two days full of exciting talks, conversations, networking and way more! Thank you all for being part of it! We hope to see you all again soon! 🥰 #neoscon #neos #community”",
    "thumbnailUrl": "https://pbs.twimg.com/media/D6YN2puXkAE_QLr.jpg:large",
    "authorName": "The Neos Project",
    "authorUrl": "https://twitter.com/neoscms",
    "publishedAt": "2019-05-12T16:04:03+00:00"
}

渲染

该包包括一个默认的渲染组件以及相应的JavaScript和CSS源代码。

使用自己的渲染器

您可以通过扩展BetterEmbed.NeosEmbed:Component.Renderer轻松注册自己的渲染组件

prototype(BetterEmbed.NeosEmbed:Component.Renderer) < prototype(Neos.Fusion:Case) {
    yourComponent {
        condition = true
        renderer = Your.Component:BetterEmbed {
            @apply.props = ${props}
        }
    }
}

资产管理

您将在Neos CMS媒体模块的“BetterEmbed”资产集合中找到导入的资产。每个资产都将标记为BetterEmbed响应记录的itemType,以便进一步分组。

BetterEmbed media module

API

该包基于BetterEmbed API端点。您可以在这里阅读API描述并测试URL。

问题和PR

如果您喜欢,可以自由创建问题以进行PR。