Debian Codegraph @

docs/socialcards.rst

raw
1 Social media card images
2 ========================
3
4 This extension will automatically generate a PNG meant for sharing documentation links on social media platforms.
5 These cards display metadata about the page that you link to, and are meant to catch the attention of readers.
6
7 See `the opengraph.xyz website`__ for a way to preview what your social media cards look like.
8 Here's an example of what the card for this page looks like:
9
10 .. image:: ./tmp/num_0.png
11 :width: 500
12
13 __ https://www.opengraph.xyz/
14
15 Disable card images
16 -------------------
17
18 To disable social media card images, use the following configuration:
19
20 .. code-block:: python
21 :caption: conf.py
22
23 ogp_social_cards = {
24 "enable": False
25 }
26
27 Update the top-right image
28 --------------------------
29
30 By default the top-right image will use the image specified by ``html_logo`` if it exists.
31 To update it, specify another path in the **image** key like so:
32
33 .. code-block:: python
34 :caption: conf.py
35
36 ogp_social_cards = {
37 "image": "path/to/image.png",
38 }
39
40 .. warning::
41
42 The image cannot be an SVG
43
44 Matplotlib does not support easy plotting of SVG images,
45 so ensure that your image is a PNG or JPEG file, not SVG.
46
47 Customize the text font
48 -----------------------
49
50 By default, the Roboto Flex font is used to render the card text.
51
52 You can specify the other font name via ``font`` key:
53
54 .. code-block:: python
55 :caption: conf.py
56
57 ogp_social_cards = {
58 "font": "Noto Sans CJK JP",
59 }
60
61 You might need to install an additional font package on your environment. Also, note that the font name needs to be
62 discoverable by Matplotlib FontManager.
63 See `Matplotlib documentation`__
64 for the information about FontManager.
65
66 __ https://matplotlib.org/stable/tutorials/text/text_props.html#default-font
67
68 Customize the card
69 ------------------
70
71 There are several customization options to change the text and look of the social media preview card.
72 Below is a summary of these options.
73
74 - **site_url**: Set a custom site URL.
75 - **line_color**: Colour of the border line at the bottom of the card, in hex format.
76
77 Example social cards
78 --------------------
79
80 Below are several social cards to give an idea for how this extension behaves with different length and size of text.
81
82 .. include:: ./tmp/embed.txt