Skip to content

Commit a4ccb8b

Browse files
committed
docs: add docs on template
1 parent cff420c commit a4ccb8b

2 files changed

Lines changed: 49 additions & 5 deletions

File tree

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
# TableauOgExtension
1+
# Tableau.OgExtension
22

3-
**TODO: Add description**
3+
[![Discord](https://img.shields.io/badge/Discord-5865F3?style=flat&logo=discord&logoColor=white&link=https://discord.gg/nNDMwTJ8)](https://discord.gg/6XdGnxVA2A)
4+
[![Hex.pm](https://img.shields.io/hexpm/v/tableau_og_extension)](https://hex.pm/packages/tableau_og_extension)
5+
[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/tableau_og_extension/)
6+
7+
The Open Graph extension for Tableau!
8+
9+
This enables you to create open graph images from a template for all of the pages in your site, utilizing [Puppeteer](https://pptr.dev/) and [Google Chrome](https://www.google.com/chrome/index.html).
10+
11+
See the [docs](https://hexdocs.pm/tableau_og_extension/Tableau.OgExtension.html) for more information.
412

513
## Installation
614

lib/tableau/extensions/og_extension.ex

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
defmodule Tableau.OgExtension do
2-
@moduledoc """
2+
@moduledoc ~S'''
33
Extension to create Open Graph images.
44
55
The Open Graph extension utilizes a user provided template, the Puppeteer Node.js module, and Google Chrome to
@@ -26,19 +26,55 @@ defmodule Tableau.OgExtension do
2626
2727
Subsequent runs will not regenerate existing images, so delete them first if you have changed your template.
2828
29+
### Template
30+
31+
The extension will render a configured template into the image. The template is configured as a module/function tuple
32+
that will be passed assigns including the Tableau page, which includes the title, permalink, etc.
33+
34+
Here is an example:
35+
36+
```elixir
37+
defmodule MySite.Og do
38+
require EEx
39+
EEx.function_from_string(
40+
:def,
41+
:template,
42+
"""
43+
<!DOCTYPE html>
44+
<html lang="en">
45+
<head>
46+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
47+
<meta charset="utf-8" />
48+
<style>
49+
<!-- my styles -->
50+
</style>
51+
</head>
52+
<body >
53+
<%= @page.title %>
54+
</body>
55+
</html>
56+
""",
57+
[:assigns]
58+
)
59+
end
60+
```
61+
62+
Configuration example can be seen below.
63+
2964
## Configuration
3065
31-
Defaults are shown below.
66+
Examples are shown below.
3267
3368
```elixir
3469
# config/config.exs
3570
3671
config :tableau, Tableau.OgExtension,
3772
enabled: true,
3873
path: "./priv/og",
74+
template: {MySite.Og, :template}
3975
log: true
4076
```
41-
"""
77+
'''
4278
use Tableau.Extension,
4379
enabled: true,
4480
key: :og,

0 commit comments

Comments
 (0)