GitXplorerGitXplorer
p

logseq-plugin-link-preview

public
122 stars
17 forks
26 issues

Commits

List of commits on branch master.
Unverified
968a730df02e668c5ef23f675ab171960b7752b1

chore(release): 2.3.0 [skip ci]

ssemantic-release-bot committed 10 months ago
Verified
fa4d810268c2c305145584936da5bb5d18aa09f8

feat(popup): dynamic colors (#126)

yyoyurec committed 10 months ago
Unverified
2e2e9bf4c698e1bd16ae1caadb42851b56dc2ede

chore(release): 2.2.10 [skip ci]

ssemantic-release-bot committed 2 years ago
Verified
78288ebab72db7936a9e6641a876650ebd72895d

fix: upgrade logseq sdk ( #124 ) (#125)

CCharlesChiuGit committed 2 years ago
Verified
4b020da77d08315b38fce86491867ecc88246eab

fix(package.json): upgrade logseq sdk (#124)

CCharlesChiuGit committed 2 years ago
Unverified
ea48cff813bb06accd290182030a5579d467e451

chore(release): 2.2.9 [skip ci]

ssemantic-release-bot committed 3 years ago

README

The README file for this repository.

Logseq Plugin Link Preview

A simple plugin to show basic link information (based on OpenGraph Protocol) for external links in Logseq.

By default when it is enabled, when you hovering any external link in Logseq, it will show the link preview. Also this plugin will register a Convert to Link Card command for you to convert the link to a link card.

Features

  • Show link preview when hovering any external link in Logseq
  • Convert the link to a link card when you use the Convert to Link Card command
  • Cache the results locally
  • Light & dark theme

Demo

How does this plugin work?

There are two modes of this plugin:

  • Hovering mode
  • Macro mode

The two modes are working very differently, but they codes are mostly shared.

Hovering Mode

It will register mouseenter and mouseleave events on all external links in the main document of Logseq. Note, in this step this plugin uses a unsafe top context of the main document, which might not work in the future.

In the listener, the plugin will extract the href attribute of the link and send a request to an API server to get the link information (the OpenGraph metadata).

Once the api returns with the link metadata (e.g., title, description, image), the plugin will

  • render them in the plugin iframe
  • resize the iframe and move its position to the hovering link

Macro Mode

Typically, user will use slash command to create a custom renderer Marco :linkpreview with the URL as the argument

{{renderer :linkpreview,https://google.com}}

When it is rendered, the logseq.App.onMacroRendererSlotted hook will fetch the link information from the API server and render it with ReactDomServer.renderToString method into the slot. The plugin will register the styles into the global context.