File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,15 @@ def make_tag(property: str, content: str) -> str:
34
34
return f'<meta property="{ property } " content="{ content } " />\n '
35
35
36
36
37
+ def make_arbitrary_tags (fields : Dict [str , Any ]) -> str :
38
+ tags = ""
39
+ for name , content in fields .items ():
40
+ if name .startswith ("og:" ):
41
+ tags += make_tag (name , content )
42
+
43
+ return tags
44
+
45
+
37
46
def get_tags (
38
47
app : Sphinx ,
39
48
context : Dict [str , Any ],
@@ -141,24 +150,22 @@ def get_tags(
141
150
elif ogp_image_alt is None and title :
142
151
tags += make_tag ("og:image:alt" , title )
143
152
153
+ # arbitrary tags
154
+ tags += make_arbitrary_tags (fields )
155
+
144
156
# custom tags
145
157
tags += "\n " .join (config ["ogp_custom_meta_tags" ])
146
158
147
159
return tags
148
160
149
161
150
- from sphinx .util import logging
151
-
152
-
153
162
def html_page_context (
154
163
app : Sphinx ,
155
164
pagename : str ,
156
165
templatename : str ,
157
166
context : Dict [str , Any ],
158
167
doctree : nodes .document ,
159
168
) -> None :
160
- logger = logging .getLogger (__name__ )
161
- logger .info (context .get ("meta" ))
162
169
if doctree :
163
170
context ["metatags" ] += get_tags (app , context , doctree , app .config )
164
171
You can’t perform that action at this time.
0 commit comments