mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-03 19:32:35 +02:00
feat(v2): embed Canny feedback widget (#1280)
* feat(v2): embed Canny feedback widget * docs(v2): Mention source of Canny widget * misc(v2): add newline
This commit is contained in:
parent
398d7c7ae4
commit
d78220a818
5 changed files with 71 additions and 3 deletions
28
v2-website/pages/feedback/index.js
Normal file
28
v2-website/pages/feedback/index.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* Copyright (c) 2017-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import React, {useEffect} from 'react';
|
||||
import canny from '../../scripts/canny';
|
||||
|
||||
import styles from './styles.module.css';
|
||||
|
||||
const BOARD_TOKEN = '054e0e53-d951-b14c-7e74-9eb8f9ed2f91';
|
||||
|
||||
function Feedback() {
|
||||
useEffect(() => {
|
||||
canny();
|
||||
window.Canny &&
|
||||
window.Canny('render', {
|
||||
boardToken: BOARD_TOKEN,
|
||||
basePath: '/feedback',
|
||||
});
|
||||
}, []);
|
||||
|
||||
return <div className={styles.feedbackPage} data-canny />;
|
||||
}
|
||||
|
||||
export default Feedback;
|
4
v2-website/pages/feedback/styles.module.css
Normal file
4
v2-website/pages/feedback/styles.module.css
Normal file
|
@ -0,0 +1,4 @@
|
|||
.feedbackPage {
|
||||
margin: 64px auto;
|
||||
max-width: 1024px;
|
||||
}
|
37
v2-website/scripts/canny.js
Normal file
37
v2-website/scripts/canny.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* Copyright (c) 2017-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// Provided by Canny.
|
||||
|
||||
function canny() {
|
||||
!(function(w, d, i, s) {
|
||||
function l() {
|
||||
if (!d.getElementById(i)) {
|
||||
var f = d.getElementsByTagName(s)[0],
|
||||
e = d.createElement(s);
|
||||
(e.type = 'text/javascript'),
|
||||
(e.async = !0),
|
||||
(e.src = 'https://canny.io/sdk.js'),
|
||||
f.parentNode.insertBefore(e, f);
|
||||
}
|
||||
}
|
||||
if ('function' != typeof w.Canny) {
|
||||
var c = function() {
|
||||
c.q.push(arguments);
|
||||
};
|
||||
(c.q = []),
|
||||
(w.Canny = c),
|
||||
'complete' === d.readyState
|
||||
? l()
|
||||
: w.attachEvent
|
||||
? w.attachEvent('onload', l)
|
||||
: w.addEventListener('load', l, !1);
|
||||
}
|
||||
})(window, document, 'canny-jssdk', 'script');
|
||||
}
|
||||
|
||||
export default canny;
|
|
@ -92,7 +92,7 @@ module.exports = function createBaseConfig(props, isServer) {
|
|||
|
||||
const jsRule = config.module
|
||||
.rule('js')
|
||||
.test(/\.js$/)
|
||||
.test(/\.jsx?$/)
|
||||
.exclude.add(filepath => {
|
||||
// Always transpile lib directory
|
||||
if (filepath.startsWith(path.join(__dirname, '..'))) {
|
||||
|
|
|
@ -104,8 +104,7 @@ class DocusaurusPluginContentPages {
|
|||
}
|
||||
|
||||
getPathsToWatch() {
|
||||
// Not needed, all pages are loaded as modules and watched by webpack.
|
||||
return [];
|
||||
return [this.contentPath];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue