On this page

TypeScript SDK and the link-preview element

The repository contains a dependency-free TypeScript client and a <link-preview> custom element. Both live in packages/sdk.

The @omnillink/sdk package is built from the repository. Its publication on the npm registry is not confirmed at this time: until then, install it from packages/sdk.

The client

TypeScript
import { createClient } from '@omnillink/sdk';

const omnillink = createClient({ baseUrl: 'https://omnillink.kayzen-lyon.com' });

const { data, meta } = await omnillink.meta('https://example.com/blog/launch');
console.log(data.title, data.image?.url, meta.cached);
OptionDefaultPurpose
baseUrlDefault–PurposeOrigin of the instance. /api/v1 is appended for you.
apiKeyDefault–PurposeSent in the x-api-key header.
fetchDefaultglobal fetchPurposeYour own implementation, for tests for instance.
timeoutMsDefault30000PurposeTime allowed for a whole request. 0 disables it.

The meta, extract, content, screenshot and pdf methods take the parameters of the API. The JSON methods resolve to { data, meta }.

The <link-preview> element

A separate entry point registers the element. It renders a preview card from /meta.

HTML
<script type="module">
  import '@omnillink/sdk/element';
</script>

<link-preview url="https://example.com/blog/launch" base-url="https://omnillink.kayzen-lyon.com"></link-preview>

React

The @omnillink/react package, in packages/react, provides the <LinkPreview> component and the useLinkMeta() hook. The component wraps the <link-preview> element with typed props. On the server it renders a plain link; in the browser it becomes the card.

React
import { LinkPreview } from '@omnillink/react';

<LinkPreview url="https://example.com/blog/launch" baseUrl="https://omnillink.kayzen-lyon.com" />;

GitHub Action

The .github/actions/link-preview action fetches the metadata of an address, exposes it as step outputs and writes a preview to the job summary. It can also take a screenshot.

YAML
- uses: kayzen-lyon/linkforge/.github/actions/link-preview@main
  id: preview
  with:
    url: https://example.com/blog/launch
    base-url: https://omnillink.kayzen-lyon.com
- run: echo "$TITLE"
  env:
    TITLE: ${{ steps.preview.outputs.title }}

The playground generates this tag for the address you are testing. The options are detailed in the README.md of the package.

Keyboard shortcuts

CtrlKor/
Open search and commands
?
Show this help
←→
Move from one tab to the next
Ctrl↵
Run the request in the playground
Esc
Close a panel or a menu

Single-key shortcuts can be turned off in the accessibility options.