@@ -98,13 +98,27 @@ def html_page_context(app, pagename, templatename, context, doctree):
98
98
context ["latest_version" ] = versioninfo [app .config .versionselector_latest_version ]
99
99
100
100
101
+ def config_hook (app , config ):
102
+ if not config .plausible_script or not config .plausible_domain :
103
+ return
104
+
105
+ app .add_js_file (config .plausible_script , {
106
+ "defer" : "defer" , "data-domain" : config .plausible_domain
107
+ })
108
+ print ("Plausible analytics script added to this build" )
109
+
110
+
101
111
def setup (app ):
102
112
app .add_config_value ("versionselector_metadata" , {}, "html" )
103
113
app .add_config_value ("versionselector_metadata_path" , "" , "html" )
104
114
app .add_config_value ("versionselector_current_version" , "" , "html" )
105
115
app .add_config_value ("versionselector_latest_version" , "master" , "html" )
106
116
117
+ app .add_config_value ("plausible_domain" , "" , "html" )
118
+ app .add_config_value ("plausible_script" , "" , "html" )
119
+
107
120
app .connect ("html-page-context" , html_page_context )
121
+ app .connect ("config-inited" , config_hook )
108
122
109
123
return {
110
124
"version" : "0.1" ,
@@ -186,6 +200,10 @@ def setup(app):
186
200
"-D" ,
187
201
"release={current}" ,
188
202
"-D" ,
203
+ "plausible_script=https://plausible.octoprint.org/js/plausible.js" ,
204
+ "-D" ,
205
+ "plausible_domain=docs.octoprint.org" ,
206
+ "-D" ,
189
207
"templates_path={templates}" ,
190
208
"-D" ,
191
209
"extensions={extensions}" ,
0 commit comments