@@ -196,10 +196,42 @@ jobs:
196
196
with :
197
197
dotnet-version : ' 8.0.x'
198
198
global-json-file : dotnet/global.json
199
+ - run : dotnet tool update -g docfx
199
200
- run : |
200
201
mkdir -p ./build/dotnet/dev/
201
202
docfx build docfx.json --output ./build/dotnet/dev/
202
203
working-directory: ./docs/dotnet
204
+ - name : insert clarity snippet to *.html
205
+ working-directory : ./docs/dotnet/build/dotnet/dev/
206
+ shell : python
207
+ run : |
208
+ import os
209
+ clarity_script = """
210
+ <script type="text/javascript">
211
+ (function(c,l,a,r,i,t,y){
212
+ c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
213
+ t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
214
+ y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
215
+ })(window, document, "clarity", "script", "lnxpe6skj1");
216
+ </script>
217
+ """
218
+
219
+ site_folder = '.'
220
+
221
+ for root, dirs, files in os.walk(site_folder):
222
+ for file in files:
223
+ if file.endswith('.html'):
224
+ html_path = os.path.join(root, file)
225
+
226
+ # insert the script into the html's head section
227
+ with open(html_path, 'r') as file:
228
+ html = file.read()
229
+ html = html.replace('</head>', clarity_script + '</head>')
230
+
231
+ with open(html_path, 'w') as file:
232
+ file.write(html)
233
+
234
+ print(f'Clarity script inserted into {html_path}')
203
235
- uses : actions/upload-artifact@v4
204
236
with :
205
237
path : " ./docs/dotnet/build"
0 commit comments