Giter Site home page Giter Site logo

logseq-plugin-link-preview's Introduction

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.

logseq-plugin-link-preview's People

Contributors

charleschiugit avatar pengx17 avatar renovate-bot avatar renovate[bot] avatar semantic-release-bot avatar yoyurec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

logseq-plugin-link-preview's Issues

Failed to load link metadata.

Couldn't fetch preview from any url. Were there some configuration should be setting? I tried to set proxy mode, but not work.

Plugin version: v2.0.0
Logseq version: v0.6.5

image

link-preview.ts(37,37): error Object is of type 'unknown'

Hi, 

I am trying to deploy the plugin on vercel.

I forked your repo and followed the steps in the readme.

  • fork this plugin repository
  • import your forked repository as a new project in Vercel
  • configure it with FRAMEWORK PRESET to Other
  • override INSTALL COMMAND in Build settings to npm i pnpm -g && pnpm i
  • click deploy. After deploy is done, you can now replace the https://logseq-plugin-link-preview.vercel.app with your own backend URL.
     

While deploying I received the error

Initially I thought it was due to the output directory dist. I tried to force the creation of the directory by modifying the build command --> mkdir -p && npm i pnpm -g && pnpm i
The output directory error went away, but the second error still exists

I added the full error log in [this gist](https://gist.github.com/Bad3r/7c5ffa0e21d0eea4f59a3b479138c849).

Make the title and extracted excerpt of the links searchable

This one is pretty simple to explain. Say, I want to render a link preview, in order to keep it cached in my database. If I then start searching for that URL, the only thing I could potentially find out about, is if the URL itself contains any of the search keywords:

image

What I 'd love to see here is the title, and excerpt also being searchable. Is this somewhat feasible?

feat: static rendering for inline card

Requested from Logseq discord server. The goal is to have the following workflow:

  1. choose "insert a static link card"
  2. let the user to put an external link
  3. the plugin fetch the OpenGraph meta data
  4. before metadata returns, render a "loading message"
  5. when metadata returns, inject a pre-rendered mockup

The main issue here is for task 5, break it down as ...

  1. render the card with ReactDOM static rendering with the given data
  2. inject style element
  3. trim any invalid char for Logseq

Link hover content with transparent background and weird font styles

Hi folks,

When I mouse over a link the preview card renders a the title and description with a transparent background, no borders and weird font styles.

Here`s an example?
image

First time I install the plugin, it works fine. After closing and reopening Logseq the error occurs and then persists.

Thanks in advance.

Regards,

José Compadre Junior

Preview doesn't resize properly when within a reference

When viewed within a reference, link preview doesn't resize itself properly and ends up overlapping the edge of the reference box as shown in video

trimmedPreview.mov

Another example, sometimes it works at a certain window size but when the window is wider the preview overflows the reference block

trimmedIntermittent.mov

Resizing behavior when viewing a preview on the page itself works as expected.

Feature request: Link card as default after pasteing a link

Context: I really missed the smooth Notion-style "bookmark" from Obsidian, and Logseq. I love that you realised how important this feature is. For me, the Link cards after pasting a link as default (instead of Link Preview after hover) would be even more handy. This could be an optional setting.

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


No npm token specified.

An npm token must be created and set in the NPM_TOKEN environment variable on your CI environment.

Please make sure to create an npm token and to set it in the NPM_TOKEN environment variable on your CI environment. The token must allow to publish to the registry https://registry.npmjs.org/.


Good luck with your project ✨

Your semantic-release bot 📦🚀

authenticate for private urls

Some link previews are blocked because the linked page requires authentication, like an issue on a private github repo. Is there a way to login to these sites so that the login cookie is stored and the link previews work correctly?

2023-07-18 10-43-ceb3d-c3a97

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/main.yml
  • actions/checkout v3
  • actions/setup-node v3
  • pnpm/action-setup v2.2.2
  • montudor/action-zip v1
npm
package.json
  • @logseq/libs ^0.0.6
  • link-preview-js ^3.0.0
  • react ^18.2.0
  • react-dom ^18.2.0
  • react-use ^17.4.0
  • swr ^1.3.0
  • use-is-typing ^1.0.3
  • valtio ^1.6.2
  • @semantic-release/changelog 6.0.1
  • @semantic-release/exec 6.0.3
  • @semantic-release/git 10.0.1
  • @semantic-release/npm 9.0.1
  • @types/react 18.0.15
  • @types/react-dom 18.0.6
  • @vitejs/plugin-react 1.3.2
  • conventional-changelog-conventionalcommits 5.0.0
  • semantic-release 19.0.3
  • typescript 4.7.4
  • vite 2.9.9
  • vite-plugin-logseq 1.1.2
  • windicss 3.5.6

  • Check this box to trigger a request for Renovate to run again on this repository

Link Preview being covered by page/block previews

When you hover over a [[]] or # link in Logseq you see a preview of the text in the page

If the text in preview has a link in it - hovering over the link causes the link preview to be hidden underneath the page/block preview

Screenshot 2023-03-27 at 11 28 02 AM

Preview shows too fast

Preview shows too fast, can be a little bit confused. Might toggle the link preview after several seconds delay or only preview when press command (or control) key.

Link preview does not work well with a non-default theme

With the Nord theme (available in marketplace), it seems that link preview popup is stuck with the default dark theme:
image
(see how the Nord background is this bluish-grey and the popup is default logseq green)
also in light theme mode:
image

While it's ok for link cards, they still get this weird-looking green border, which turns blue on hover:
image
image
personally, both of those don't look good too (way too acid looking next to the pale dark background)

Issue with Static Link Cards, Using macros?

Hello!

I'm using the latest version of your plugin on the latest version of Logseq on Windows 10. I really love using the Link Cards function, but the static link cards haven't worked for me for as long as I've used this plugin:

image

I tend to stick to the regular link card slash command, but the issue is that on mobile, the links just don't appear:

Desktop
image

Mobile

scrcpy_8XsPBQQY4M.mp4

I wonder if there's another way of managing the link cards to ensure that the links appear, even on mobile / web app / any version that doesn't have the plugin. Perhaps this should be a macro?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.