Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@ampproject/amp-embedly-card
Advanced tools
Readme
The Bento Embedly Card component provides you with responsive and shareable embeds to drive the reach of your websites,
blog posts, and articles from any URL using Embedly cards. Use it as a web component <bento-embedly-card>
, or a Preact/React functional component <BentoEmbedlyCard>
.
Cards are the easiest way to leverage Embedly. For any media, cards provide a responsive embed with built-in embed analytics.
If you have a paid plan, use the <bento-embedly-key>
or <BentoEmbedlyContext.Provider>
component to set your API key. You just need one Bento Embedly key per page to remove Embedly's branding from the cards. Within your page, you can include one or multiple Bento Embedly Card instances.
You must include each Bento component's required CSS library to guarantee proper loading and before adding custom styles. Or use the light-weight pre-upgrade styles available inline. See Layout and style.
The examples below demonstrate use of the <bento-embedly-card>
web component.
[example preview="top-frame" playground="false"]
Install via npm:
npm install @ampproject/bento-embedly-card
import '@ampproject/bento-embedly-card';
[/example]
<script>
[example preview="top-frame" playground="false"]
<head>
<script src="https://cdn.ampproject.org/custom-elements-polyfill.js"></script>
<!-- These styles prevent Cumulative Layout Shift on the unupgraded custom element -->
<style data-bento-boilerplate>
bento-embedly-card {
display: block;
overflow: hidden;
position: relative;
}
</style>
<script async src="https://cdn.ampproject.org/v0/bento-embedly-card-1.0.js"></script>
<style>
bento-embedly-card {
width: 375px;
height: 472px;
}
</style>
</head>
<body>
<bento-embedly-key value="12af2e3543ee432ca35ac30a4b4f656a">
</bento-embedly-key>
<bento-embedly-card
data-url="https://twitter.com/AMPhtml/status/986750295077040128"
data-card-theme="dark"
data-card-controls="0"
>
</bento-embedly-card>
<bento-embedly-card id="my-url" data-url="https://www.youtube.com/watch?v=LZcKdHinUhE">
</bento-embedly-card>
<div class="buttons" style="margin-top: 8px;">
<button id="change-url">
Change embed
</button>
</div>
<script>
(async () => {
const embedlyCard = document.querySelector('#my-url');
await customElements.whenDefined('bento-embedly-card');
// set up button actions
document.querySelector('#change-url').onclick = () => {
embedlyCard.setAttribute('data-url', 'https://www.youtube.com/watch?v=wcJSHR0US80')
}
})();
</script>
</body>
[/example]
Each Bento component has a small CSS library you must include to guarantee proper loading without content shifts. Because of order-based specificity, you must manually ensure that stylesheets are included before any custom styles.
<link rel="stylesheet" type="text/css" href="https://cdn.ampproject.org/v0/amp-embedly-card-1.0.css">
Alternatively, you may also make the light-weight pre-upgrade styles available inline:
<style data-bento-boilerplate>
bento-embedly-card {
display: block;
overflow: hidden;
position: relative;
}
</style>
Container type
The bento-embedly-card
component has a defined layout size type. To ensure the component renders correctly, be sure to apply a size to the component and its immediate children (slides) via a desired CSS layout (such as one defined with height
, width
, aspect-ratio
, or other such properties):
bento-embedly-card {
height: 100px;
width: 100%;
}
data-url
The URL to retrieve embedding information.
data-card-embed
The URL to a video or rich media. Use with static embeds like articles, instead of using the static page content in the card, the card will embed the video or rich media.
data-card-image
The URL to an image. Specifies which image to use in article cards when
data-url
points to an article. Not all image URLs are supported, if the image
is not loaded, try a different image or domain.
data-card-controls
Enables share icons.
0
: Disable share icons.1
: Enable share iconsThe default is 1
.
data-card-align
Aligns the card. The possible values are left
, center
and right
. The
default value is center
.
data-card-recommend
When recommendations are supported, it disables embedly recommendations on video and rich cards. These are recommendations created by embedly.
0
: Disables embedly recommendations.1
: Enables embedly recommendations.The default value is 1
.
data-card-via
(optional)Specifies the via content in the card. This is a great way to do attribution.
data-card-theme
(optional)Allows settings the dark
theme which changes the background color of the main
card container. Use dark
to set this theme. For dark backgrounds it's better
to specify this. The default is light
, which sets no background color of the
main card container.
Define a title
attribute for the component to propagate to the underlying <iframe>
element. The default value is "Embedly card"
.
The examples below demonstrate use of the <BentoEmbedlyCard>
as a functional component usable with the Preact or React libraries.
[example preview="top-frame" playground="false"]
Install via npm:
npm install @ampproject/bento-embedly-card
import React from 'react';
import { BentoEmbedlyCard } from '@ampproject/bento-embedly-card/react';
import '@ampproject/bento-embedly-card/styles.css';
function App() {
return (
<BentoEmbedlyContext.Provider value={apiKey: '12af2e3543ee432ca35ac30a4b4f656a'}>
<BentoEmbedlyCard url="https://www.youtube.com/watch?v=LZcKdHinUhE">
</BentoEmbedlyCard>
</BentoEmbedlyContext.Provider>
);
}
[/example]
Container type
The BentoEmbedlyCard
component has a defined layout size type. To ensure the component renders correctly, be sure to apply a size to the component and its immediate children (slides) via a desired CSS layout (such as one defined with height
, width
, aspect-ratio
, or other such properties). These can be applied inline:
<BentoEmbedlyCard style={{width: '300px', height: '100px'}} url="https://www.youtube.com/watch?v=LZcKdHinUhE">
</BentoEmbedlyCard>
Or via className
:
<BentoEmbedlyCard className='custom-styles' url="https://www.youtube.com/watch?v=LZcKdHinUhE">
</BentoEmbedlyCard>
.custom-styles {
height: 100px;
width: 100%;
}
url
The URL to retrieve embedding information.
cardEmbed
The URL to a video or rich media. Use with static embeds like articles, instead of using the static page content in the card, the card will embed the video or rich media.
cardImage
The URL to an image. Specifies which image to use in article cards when
data-url
points to an article. Not all image URLs are supported, if the image
is not loaded, try a different image or domain.
cardControls
Enables share icons.
0
: Disable share icons.1
: Enable share iconsThe default is 1
.
cardAlign
Aligns the card. The possible values are left
, center
and right
. The
default value is center
.
cardRecommend
When recommendations are supported, it disables embedly recommendations on video and rich cards. These are recommendations created by embedly.
0
: Disables embedly recommendations.1
: Enables embedly recommendations.The default value is 1
.
cardVia
(optional)Specifies the via content in the card. This is a great way to do attribution.
cardTheme
(optional)Allows settings the dark
theme which changes the background color of the main
card container. Use dark
to set this theme. For dark backgrounds it's better
to specify this. The default is light
, which sets no background color of the
main card container.
Define a title
attribute for the component to propagate to the underlying <iframe>
element. The default value is "Embedly card"
.
FAQs
AMP HTML amp-embedly-card Component
The npm package @ampproject/amp-embedly-card receives a total of 1 weekly downloads. As such, @ampproject/amp-embedly-card popularity was classified as not popular.
We found that @ampproject/amp-embedly-card demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 16 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.