GithubHelp home page GithubHelp logo

geizhals-preisvergleich / geizhals-og-image Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 1.81 MB

Experiment for generating dynamic open graph images

License: European Union Public License 1.2

HTML 1.86% Svelte 65.64% JavaScript 25.92% SCSS 6.58%
opengraph-images satori svelte sveltekit

geizhals-og-image's Introduction

Geizhals OG Images

Experiment to leverage satori and SvelteKit to generate dynamic open graph images for Geizhals product pages. This application houses both the image generation part as well as an Editor for testing/debugging purposes.

og

The content of the generated image can be set by specifying GET parameters (eg. /og?title=this%20is%20a%20title).

Customizing

To change the content and design of the og image, modify the contents of src/lib/Card.svelte.

Inputs/Parameters

The list of parameters is defined in src/routes/og/extract-params.js. Changes to the parameters also need to be applied to the markup in Card.svelte as well as in Form.svelte (for the editor).

Fonts

This example uses Inter font. If you want to use a different font, place the woff files in $lib/fonts and load them in src/routes/og/+server.js.

Run dev server

Install dependencies with npm install (or pnpm install or yarn), then start a development server:

npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open

By default, the dev server will available at http://localhost:5173/

Images

With the (dev) server running, visit http://localhost:5173/og/ and append the parameters for required for the image, e.g. http://localhost:5173/og?title=Nintendo+Switch+OLED+schwarz%2Fwei%C3%9F&image=https%3A%2F%2Fgzhls.at%2Fi%2F76%2F69%2F2557669-n0.jpg&variants=true&ratings=5&ratings_count=7

Editor

editor

For better testing and developing, a simple editor interface can be found at http://localhost:5173/og/editor/

When any of the inputs values change, the image is re-generated. While working on the Card.svelte component, you can also activate "Auto Refresh", which will refresh the image every 4 seconds to show the result of Card.svelte with the current parameters.

Building

To create a production version of your app:

npm run build

You can preview the production build with npm run preview.

See https://kit.svelte.dev/docs/adapters on how to deploy the application. Currently this application uses adapter-vercel for deployments to vercel. Change as required.

Preliminary work

geizhals-og-image's People

Contributors

mgrubinger avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

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.