Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feedback widget to docs with flarelytics integration #9129

Merged
merged 5 commits into from Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/extra/feedback.js
@@ -0,0 +1,21 @@
var feedback = document.forms.feedback
feedback.hidden = false

feedback.addEventListener("submit", function(ev) {
ev.preventDefault()

var data = ev.submitter.getAttribute("data-md-value")
feedback.firstElementChild.disabled = true

var note = feedback.querySelector(
`.md-feedback__note [data-md-value='${data}']`
)
if (note)
note.hidden = false

if (data == 1) {
window.flarelytics_event('thumbsUp');
} else if (data == 0) {
window.flarelytics_event('thumbsDown');
}
})
15 changes: 15 additions & 0 deletions mkdocs.yml
Expand Up @@ -36,6 +36,20 @@ edit_uri: edit/main/docs/
extra:
version:
provider: mike
analytics:
feedback:
title: Was this page helpful?
ratings:
- icon: material/thumb-up-outline
name: This page was helpful
data: 1
note: >-
Thanks for your feedback!
- icon: material/thumb-down-outline
name: This page could be improved
data: 0
note: >-
Thanks for your feedback!

# https://www.mkdocs.org/user-guide/configuration/#validation
validation:
Expand All @@ -47,6 +61,7 @@ extra_css:
- 'extra/terminal.css'
- 'extra/tweaks.css'
extra_javascript:
- 'extra/feedback.js'
- 'extra/fluff.js'
- 'https://samuelcolvin.github.io/mkdocs-run-code/run_code_main.js'

Expand Down