Git Product home page Git Product logo

astro-link-preview's Introduction

astro-link-preview

version

This Astro integration generates preview images for external links.


demo

Features

  • Supports both Static Site Generation (SSG) and Server-Side Rendering (SSR) modes.
  • Automatically optimizes images to improve loading performance.
  • Provides customizable styles for preview images.

Installation

# Using NPM
npm install astro-link-preview
# Using Yarn
yarn add astro-link-preview
# Using PNPM
pnpm add astro-link-preview

Config

// astro.config.mjs
import {defineConfig} from "astro/config"
import linkPreview from "astro-link-preview"
export default defineConfig({
  integrations: [
    linkPreview()
  ],
})

Options

import type { LaunchOptions } from 'playwright'

export interface Options {
  /**
   * Whether to log stats
   * @default true
   */
  logStats?: boolean
  /**
   * proxy settings
   */
  proxy?: LaunchOptions['proxy']
  /**
   * preview image format
   * @default 'jpg'
   */
  previewImageFormat?: 'png' | 'jpg'
  /**
   * whether to allow image previews on mobile devices
   * @default false
   */
  enableOnMobile?: boolean
}

How to use

see example

License

MIT ยฉ nemurubaka

astro-link-preview's People

Contributors

cijiugechu avatar renovate[bot] 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

Watchers

 avatar

astro-link-preview's Issues

Dependency Dashboard

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

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency @types/node to v18.19.28
  • chore(deps): update dependency typescript to v5.4.3
  • fix(deps): update dependency @astrojs/node to v5.3.6
  • fix(deps): update dependency @napi-rs/image to v1.9.1
  • fix(deps): update dependency @node-rs/xxhash to v1.7.0
  • fix(deps): update dependency @rollup/pluginutils to v5.1.0
  • fix(deps): update dependency astro to v2.10.15
  • fix(deps): update dependency playwright to v1.42.1
  • fix(deps): update dependency astro to v4
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

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

Detected dependencies

npm
package.json
  • prettier ^2.8.8
  • tsup ^7.3.0
  • typescript ^5.1.6
  • vitest ^0.34.6
  • pnpm 8.10.4
packages/core/package.json
  • @napi-rs/image ^1.7.0
  • @node-rs/xxhash ^1.4.2
  • @rollup/pluginutils ^5.0.5
  • kleur ^4.1.4
  • parse5-html-rewriting-stream ^7.0.0
  • playwright ^1.40.0
  • @types/node ^18.11.18
  • astro ^2.4.4
  • tsup ^7.3.0
  • typescript ^5.1.6
  • vite ^4.5.0
  • astro >=2.0.0
  • node >=16.0.0
packages/playground-ssr/package.json
  • astro ^2.6.0
  • @astrojs/node ^5.2.0
packages/playground/package.json
  • astro ^2.4.4
  • @astrojs/markdown-remark ^2.2.0
  • hast-util-select 6.0.1
  • rehype-autolink-headings ^6.1.1
  • rehype-slug ^5.0.1
  • rehype-toc ^3.0.2
  • remark-code-titles ^0.1.2

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

HTTP HEADERS ISSUE

Hey

I saw that your lib takes all the links on the page to be able to create the link-preview

const anchorElements = document.querySelectorAll('a')

It happens that when there is a link that does not have HTTP Headers, the application breaks. For example:

Native email links that end up crashing the application when hovering element

<a href="mailto:[email protected]">Email</a>

Error that is thrown:

  Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
  code: 'ERR_HTTP_HEADERS_SENT'

Would there be any way to validate whether the link starts with http or https? Something like that:

href && (href.startsWith('http://') || href.startsWith('https://'));

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.