refactor: clean Canny integration + rename 'Feedback' to 'Feature Requests' + improve TS doc page (#5389)

* Better Canny integration

* Add missing netlify redirects

* polish

* TS doc: mention it's possible to use JSDoc in config

* issue templates: use /feature-requests new url
This commit is contained in:
Sébastien Lorber 2021-08-20 11:42:13 +02:00 committed by GitHub
parent 974644d16b
commit f40ce05102
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 95 additions and 66 deletions

View file

@ -8,34 +8,30 @@
import React, {useEffect} from 'react';
import Layout from '@theme/Layout';
import canny from '../../scripts/canny';
import cannyScript from './cannyScript';
import clsx from 'clsx';
import styles from './styles.module.css';
const BOARD_TOKEN = '054e0e53-d951-b14c-7e74-9eb8f9ed2f91';
function Feedback() {
function FeatureRequests() {
useEffect(() => {
canny();
(window as any).Canny &&
(window as any).Canny('render', {
boardToken: BOARD_TOKEN,
basePath: '/feedback',
});
cannyScript();
const Canny = (window as any).Canny;
Canny('render', {
boardToken: BOARD_TOKEN,
basePath: '/feature-requests',
});
}, []);
return (
<Layout title="Feedback" description="Docusaurus 2 Feedback page">
<Layout title="Feedback" description="Docusaurus 2 Feature Requests page">
<main
className={clsx(
'container',
'margin-vert--xl',
styles.feedbackBackground,
)}
className={clsx('container', 'margin-vert--lg', styles.main)}
data-canny
/>
</Layout>
);
}
export default Feedback;
export default FeatureRequests;

View file

@ -0,0 +1,22 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @type {import('@docusaurus/types').Plugin} */
function FeatureRequestsPlugin() {
return {
name: 'feature-requests-plugin',
contentLoaded({actions}) {
actions.addRoute({
path: '/feature-requests',
exact: false,
component: '@site/src/featureRequests/FeatureRequestsPage',
});
},
};
}
module.exports = FeatureRequestsPlugin;

View file

@ -7,7 +7,7 @@
// Provided by Canny.
function canny() {
function cannyScript() {
!(function (w, d, i, s) {
function l() {
if (!d.getElementById(i)) {
@ -34,4 +34,4 @@ function canny() {
})(window, document, 'canny-jssdk', 'script');
}
export default canny;
export default cannyScript;

View file

@ -5,8 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/
.feedbackBackground {
.main {
padding: var(--ifm-spacing-horizontal);
border-radius: 4px;
background: var(--ifm-color-feedback-background);
min-height: 500px;
}

View file

@ -1,35 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import Layout from '@theme/Layout';
import Feedback from '../pages/feedback';
function NotFound({location}: {location: {pathname: string}}): JSX.Element {
if (/^\/\bfeedback\b/.test(location.pathname)) {
return <Feedback />;
} else {
return (
<Layout title="Page Not Found">
<main className="container margin-vert--xl" data-canny>
<div className="row">
<div className="col col--6 col--offset-3">
<h1 className="hero__title">Page Not Found</h1>
<p>We could not find what you were looking for.</p>
<p>
Please contact the owner of the site that linked you to the
original URL and let them know their link is broken.
</p>
</div>
</div>
</main>
</Layout>
);
}
}
export default NotFound;