Skip to content

Commit 58a3285

Browse files
committed
add clarity
1 parent 6749382 commit 58a3285

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

.github/workflows/docs.yml

+32
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,42 @@ jobs:
196196
with:
197197
dotnet-version: '8.0.x'
198198
global-json-file: dotnet/global.json
199+
- run: dotnet tool update -g docfx
199200
- run: |
200201
mkdir -p ./build/dotnet/dev/
201202
docfx build docfx.json --output ./build/dotnet/dev/
202203
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}')
203235
- uses: actions/upload-artifact@v4
204236
with:
205237
path: "./docs/dotnet/build"

0 commit comments

Comments
 (0)