Skip to content

Commit 0ae696b

Browse files
cjyabrahamjriv01
authored andcommitted
Add feedback buttons to pages
Signed-off-by: Chris Abraham <[email protected]>
1 parent 258175d commit 0ae696b

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

website/config.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ sidebar_search_disable = false
133133
[params.ui.feedback]
134134
enable = true
135135
# The responses that the user sees after clicking "yes" (the page was helpful) or "no" (the page was not helpful).
136-
yes = 'Glad to hear it! Please <a href="https://github.com/cncf/cartografos/issues/new">tell us how we can improve</a>.'
137-
no = 'Sorry to hear that. Please <a href="https://github.com/cncf/cartografos/issues/new">tell us how we can improve</a>.'
136+
yes = 'Glad to hear it! Please <a href="https://github.com/cncf/tag-security/issues/new">tell us how we can improve</a>.'
137+
no = 'Sorry to hear that. Please <a href="https://github.com/cncf/tag-security/issues/new">tell us how we can improve</a>.'
138138

139139
# Adds a reading time to the top of each doc.
140140
# If you want this feature, but occasionally need to remove the Reading time from a single page,

website/layouts/_default/content.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<div class="td-content">
2+
<h1>{{ .Title }}</h1>
3+
{{ with .Params.description }}<div class="lead">{{ . | markdownify }}</div>{{ end }}
4+
{{ if (and (not .Params.hide_readingtime) (.Site.Params.ui.readingtime.enable)) }}
5+
{{ partial "reading-time.html" . }}
6+
{{ end }}
7+
{{ .Content }}
8+
{{ if (and (not .Params.hide_feedback) (.Site.Params.ui.feedback.enable)) }}
9+
{{ partial "feedback.html" .Site.Params.ui.feedback }}
10+
<br />
11+
{{ end }}
12+
{{ if (.Site.Params.DisqusShortname) }}
13+
<br />
14+
{{ partial "disqus-comment.html" . }}
15+
{{ end }}
16+
<div class="text-muted mt-5 pt-3 border-top">{{ partial "page-meta-lastmod.html" . }}</div>
17+
</div>

website/layouts/partials/feedback.html

+8-11
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,18 @@ <h2 class="feedback--title">Feedback</h2>
3535
noButton.disabled = true;
3636
};
3737
const sendFeedback = (value) => {
38-
if (typeof ga !== 'function') return;
39-
const args = {
40-
command: 'send',
41-
hitType: 'event',
42-
category: 'Helpful',
43-
action: 'click',
44-
label: window.location.pathname,
45-
value: value
46-
};
47-
ga(args.command, args.hitType, args.category, args.action, args.label, args.value);
38+
if (typeof gtag !== 'function') return;
39+
gtag('event', 'page_helpful', {
40+
'event_category': 'Helpful',
41+
'event_label': window.location.href,
42+
'value': value
43+
});
4844
};
4945
yesButton.addEventListener('click', () => {
5046
yesResponse.classList.add('feedback--response__visible');
5147
disableButtons();
52-
sendFeedback(1);
48+
{{ $maxValue := .max_value | default 100 -}}
49+
sendFeedback({{ $maxValue }});
5350
});
5451
noButton.addEventListener('click', () => {
5552
noResponse.classList.add('feedback--response__visible');

0 commit comments

Comments
 (0)