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

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

Merged
merged 5 commits into from
Aug 20, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
blank_issues_enabled: false
contact_links:
- name: 🚀 Feature request
url: https://docusaurus.io/feedback/
url: https://docusaurus.io/feature-requests
about: The Canny board to send us feature requests, vote and measure the interest of users. Useful to submit a featurre request when you have an idea but no concrete api design proposal.
- name: ❓ Simple question - Discord chat
url: https://discord.gg/docusaurus
Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ labels: 'feature, needs triage'
IMPORTANT:
- We expect you to submit a feature request including a real design (API / UI...), not just a basic idea
- The design does not have to be perfect, we'll discuss it and fix it if needed
- For a more "casual" feature requests, consider using Canny instead: https://docusaurus.io/feedback
- For a more "casual" feature requests, consider using Canny instead: https://docusaurus.io/feature-requests
-->

## 🚀 Feature
Expand All @@ -19,7 +19,7 @@ labels: 'feature, needs triage'

(Write your answer here.)

### Has this been requested on [Canny](https://docusaurus.io/feedback)?
### Has this been requested on [Canny](https://docusaurus.io/feature-requests)?

(Please post the Canny link, it is helpful to see how much interest there is for this feature)

Expand All @@ -38,7 +38,7 @@ labels: 'feature, needs triage'

<!--
What happens if you skip this step? This issue will be automatically closed.
Your feature request is just an idea for now, please use Canny for that: https://docusaurus.io/feedback
Your feature request is just an idea for now, please use Canny for that: https://docusaurus.io/feature-requests
-->

## Have you tried building it?
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/proposal.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ labels: 'proposal, needs triage'

<!--
This is not for feature requests.
Consider requesting the feature on https://docusaurus.io/feedback instead.
Consider requesting the feature on https://docusaurus.io/feature-requests instead.
-->

## 💥 Proposal
Expand Down
2 changes: 1 addition & 1 deletion website/community/0-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ There are many online forums which are a great place for discussion about best p

## Feature requests {#feature-requests}

For new feature requests, you can create a post on our [Canny board](/feedback), which is a handy tool for roadmapping and allows for sorting by upvotes, which gives the core team a better indicator of what features are in high demand, as compared to GitHub issues which are harder to triage. Refrain from making a Pull Request for new features (especially large ones) as someone might already be working on it or will be part of our roadmap. Talk to us first!
For new feature requests, you can create a post on our [feature requests board (Canny)](/feature-requests), which is a handy tool for roadmapping and allows for sorting by upvotes, which gives the core team a better indicator of what features are in high demand, as compared to GitHub issues which are harder to triage. Refrain from making a Pull Request for new features (especially large ones) as someone might already be working on it or will be part of our roadmap. Talk to us first!

## News {#news}

Expand Down
2 changes: 1 addition & 1 deletion website/docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,4 @@ In comparison with statically generated HTML and interactivity added using `<scr

If you find issues with the documentation or have suggestions on how to improve the documentation or the project in general, please [file an issue](https://github.com/facebook/docusaurus) for us, or send a tweet mentioning the [@docusaurus](https://twitter.com/docusaurus) Twitter account.

For new feature requests, you can create a post on our [Canny board](/feedback), which is a handy tool for roadmapping and allows for sorting by upvotes, which gives the core team a better indicator of what features are in high demand, as compared to GitHub issues which are harder to triage. Refrain from making a Pull Request for new features (especially large ones) as someone might already be working on it or will be part of our roadmap. Talk to us first!
For new feature requests, you can create a post on our [feature requests board (Canny)](/feature-requests), which is a handy tool for roadmapping and allows for sorting by upvotes, which gives the core team a better indicator of what features are in high demand, as compared to GitHub issues which are harder to triage. Refrain from making a Pull Request for new features (especially large ones) as someone might already be working on it or will be part of our roadmap. Talk to us first!
40 changes: 40 additions & 0 deletions website/docs/typescript-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ id: typescript-support
title: TypeScript Support
---

Docusaurus is written in TypeScript, and provide first-class TypeScript support.

## Initialization {#initialization}

Docusaurus supports writing and using TypeScript theme components. If the init template provides a Typescript variant, you can directly initialize a site with full TypeScript support by using the `--typescript` flag.
Expand Down Expand Up @@ -34,6 +36,44 @@ Docusaurus doesn't use this `tsconfig.json` to compile your project. It is added

Now you can start writing TypeScript theme components.

## Typing the config file {#typing-config}

It is **not possible** to use a TypeScript config file in Docusaurus, unless you compile it yourself to JavaScript.

We recommend using [JSDoc type annotations](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html):

```js title="docusaurus.config.js
// highlight-start
/** @type {import('@docusaurus/types').Plugin} */
// highlight-end
function MyPlugin(context, options) {
return {
name: 'my-plugin',
};
}

// highlight-start
/** @type {import('@docusaurus/types').DocusaurusConfig} */
// highlight-end
const config = {
title: 'Docusaurus',
tagline: 'Build optimized websites quickly, focus on your content',
organizationName: 'facebook',
projectName: 'docusaurus',
plugins: [MyPlugin],
};

module.exports = config;
```

:::tip

Type annotations are very useful and help your IDE understand the type of config objects!

The best IDEs (VSCode, WebStorm, Intellij...) will provide a nice auto-completion experience.

:::

## Swizzling TypeScript theme components {#swizzling-typescript-theme-components}

For themes that supports TypeScript theme components, you can add the `--typescript` flag to the end of swizzling command to get TypeScript source code. For example, the following command will generate `index.tsx` and `styles.module.css` into `src/theme/Footer`.
Expand Down
5 changes: 3 additions & 2 deletions website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ const TwitterSvg =
clientModules: [require.resolve('./_dogfooding/clientModuleExample.ts')],
themes: ['@docusaurus/theme-live-codeblock'],
plugins: [
require('./src/featureRequests/FeatureRequestsPlugin'),
[
'@docusaurus/plugin-content-docs',
{
Expand Down Expand Up @@ -414,8 +415,8 @@ const TwitterSvg =
href: 'https://stackoverflow.com/questions/tagged/docusaurus',
},
{
label: 'Feedback',
to: 'feedback',
label: 'Feature Requests',
to: '/feature-requests',
},
{
label: 'Discord',
Expand Down
4 changes: 2 additions & 2 deletions website/sidebarsCommunity.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ module.exports = {
},
{
type: 'link',
href: '/feedback',
label: 'Feedback',
href: '/feature-requests',
label: 'Feature Requests',
},
{
type: 'link',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
22 changes: 22 additions & 0 deletions website/src/featureRequests/FeatureRequestsPlugin.js
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

// Provided by Canny.

function canny() {
function cannyScript() {
!(function (w, d, i, s) {
function l() {
if (!d.getElementById(i)) {
Expand All @@ -34,4 +34,4 @@ function canny() {
})(window, document, 'canny-jssdk', 'script');
}

export default canny;
export default cannyScript;
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
35 changes: 0 additions & 35 deletions website/src/theme/NotFound.tsx

This file was deleted.

4 changes: 4 additions & 0 deletions website/static/_redirects
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ https://docusaurus.io/docs/zh-cn/* https://v1.docusaurus.io/docs/zh-cn/:spl
# Redirect Docusaurus v1 blog RSS feed
/blog/feed.xml /blog/rss.xml


# Feature requests redirects
/feedback/* /feature-requests/:splat 301!
/feature-requests/* /feature-requests 200
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,4 @@ In comparison with statically generated HTML and interactivity added using `<scr

If you find issues with the documentation or have suggestions on how to improve the documentation or the project in general, please [file an issue](https://github.com/facebook/docusaurus) for us, or send a tweet mentioning the [@docusaurus](https://twitter.com/docusaurus) Twitter account.

For new feature requests, you can create a post on our [Canny board](/feedback), which is a handy tool for roadmapping and allows for sorting by upvotes, which gives the core team a better indicator of what features are in high demand, as compared to GitHub issues which are harder to triage. Refrain from making a Pull Request for new features (especially large ones) as someone might already be working on it or will be part of our roadmap. Talk to us first!
For new feature requests, you can create a post on our [feature requests board (Canny)](/feature-requests), which is a handy tool for roadmapping and allows for sorting by upvotes, which gives the core team a better indicator of what features are in high demand, as compared to GitHub issues which are harder to triage. Refrain from making a Pull Request for new features (especially large ones) as someone might already be working on it or will be part of our roadmap. Talk to us first!
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,4 @@ In comparison with statically generated HTML and interactivity added using `<scr

If you find issues with the documentation or have suggestions on how to improve the documentation or the project in general, please [file an issue](https://github.com/facebook/docusaurus) for us, or send a tweet mentioning the [@docusaurus](https://twitter.com/docusaurus) Twitter account.

For new feature requests, you can create a post on our [Canny board](/feedback), which is a handy tool for roadmapping and allows for sorting by upvotes, which gives the core team a better indicator of what features are in high demand, as compared to GitHub issues which are harder to triage. Refrain from making a Pull Request for new features (especially large ones) as someone might already be working on it or will be part of our roadmap. Talk to us first!
For new feature requests, you can create a post on our [feature requests board (Canny)](/feature-requests), which is a handy tool for roadmapping and allows for sorting by upvotes, which gives the core team a better indicator of what features are in high demand, as compared to GitHub issues which are harder to triage. Refrain from making a Pull Request for new features (especially large ones) as someone might already be working on it or will be part of our roadmap. Talk to us first!