demainilpleut-opengraph

command module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2023 License: MIT Imports: 4 Imported by: 0

README

demainilpleut-opengraph

demainilpleut.dev's Opengraph image generator.

It is a cli tool written in Go that can be called from the main project to generate the Opengraph images for demainilpleut's articles.

This project was born out of the frustration of doing a similar thing with a node script, that was using a lot of dependecies, constantly updated and breaking my build.

By rewriting this tool with Go, I can generate a binary and let it run for YEARS without touching it.

Prerequisites

  • go >= 1.21

Fonts are available in the config/fonts/ directory (Arial by default). Image templates are in the config/templates/ directory.

Installation

Clone the repository.

git clone https://github.com/jveillet/demainilpleut-opengraph.git

Build the binary.

go build -o opengraph

Building without cgo (disables calling C code (import "C"))

CGO_ENABLED=0 go build -o opengraph

Or run via source.

go run main.go

Configuration

Create a .env file at the root of the project, then add the two needed variables.

touch .env && OG_IMG_PATH=config/templates >> .env && OG_FONTS_PATH=config/fonts >> .env

Usage

NAME:
   Opengraph - demainilpleut's OpenGraph images generation

USAGE:
   Opengraph [global options] command [command options] [arguments...]

VERSION:
   1.2.0

COMMANDS:
   generate, g  Generate an OpenGraph image
   help, h      Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print the version
Generate
NAME:
   Opengraph generate - Generate an OpenGraph image

USAGE:
   Opengraph generate [command options] [arguments...]

OPTIONS:
   --title TITLE, -t TITLE     The post TITLE
   --author AUTHOR, -a AUTHOR  The post AUTHOR
   --file PATH, -f PATH        Save the generated image in PATH
   --labels LABELS, -l LABELS  The post LABELS
   --date DATE, -d DATE        The post DATE in YYYY-MM-DD format
   --help, -h                  show help

Example:

Via source

go run main.go generate -a johndoe -d 1970-01-01 -f ./dist/out.png -l tag1,tag2,tag3 -t "The quick brown fox jumps over the lazy dog"

Via binary

./opengraph generate -a johndoe -d 1970-01-01 -f ./dist/out.png -l tag1,tag2,tag3 -t "The quick brown fox jumps over the lazy dog"

Can I use this ?

Well, it is specifically tailored to run for demainilpleut.dev, so it might not be usefull to you.

But if you want to explore code, or adapt it to your own needs, knock yourself out 😄️.

Documentation

Overview

Copyright © 2023 Jérémie Veillet

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL