dev-resources.site
for different kinds of informations.
Liquor Tags - Fetch OpenGraph data and Render the output
Published at
3/26/2024
Categories
elixir
tags
liquor
embed
Author
Camilo
Liquor Tags. Inspired by dev.to embed tags (liquid tags),
takes Open Graph data from URLs and generate output using pseudo EEx templates.
Useful when creating previews of websites using Open Graph data.
Installation
Mix.install([
{:liquor, "~> 1.0.0"},
{:req, "~> 0.4.14"}, # Just for demostration
{:kino, "~> 0.12.3"} # Just for demostration
])
alias Liquor.Tags.Tag
content = """
{% github ElixirCL %}
{% embed https://ninjas.cl %}
"""
tags = [
Tag.new("github", "Github: <%= og.url %>", "https://github.com"),
Tag.new("embed", "Website: <%= og.title %>")
]
# Fetch only needs to return the HTML string
fetch = fn url -> Req.get!(url) |> then(& &1.body) end
Liquor.render(content, tags, fetch)
|> Kino.Text.new()
Renders
Github: https://github.com/ElixirCL
Website: Ninja Software Chile (Ninjas.cl)
Articles
12 articles in total
Odin for Alchemists
read article
Odin's Elixir
read article
驴Trabajo Remoto o H铆brido?
read article
Super Club Net: Libro de Introducci贸n a HTML, CSS y JS
read article
Desaf铆o de Nombres y Apellidos
read article
La revista Club Nintendo y su curso de HTML
read article
Historia de la BeamVM
read article
Introducci贸n a Elixir
read article
Documenta tu Evoluci贸n Profesional
read article
驴Me conviene un Bootcamp Tecnol贸gico?
read article
Liquor Tags - Fetch OpenGraph data and Render the output
currently reading
Protecting your content against AI scrappers
read article
Featured ones: