Create a custom unfurl action
Build an integration that allows you to unfurl and display embedded links on a page
Create an integration
Example
import {
createIntegration,
createComponent,
} from '@gitbook/runtime';
const UnfurlExample = createComponent<{
url?: string;
}>({
componentId: 'unfurl-example',
async action(element, action) {
switch (action.action) {
case '@link.unfurl': {
// The pasted URL
const { url } = action;
return {
props: {
url,
},
};
}
}
return element;
},
async render(element, context) {
const { url } = element.props;
return (
<block>
<webframe
source={{
url: url
}}
/>
</block>
);
},
});
export default createIntegration({
components: [UnfurlExample],
});Configure the block to unfurl urls
How it works
Last updated
Was this helpful?