From 9cc95ddf0ad18dfe6b4f075d8263eff516c804de Mon Sep 17 00:00:00 2001 From: Christian Murphy Date: Wed, 17 Nov 2021 10:10:22 -0700 Subject: [PATCH] Add issue templates, reference codesandbox starters Closes GH-16. Reviewed-by: Titus Wormer --- .github/ISSUE_TEMPLATE/1-bug.md | 41 ----- .github/ISSUE_TEMPLATE/1-bug.yml | 145 ++++++++++++++++++ .github/ISSUE_TEMPLATE/2-feature.md | 31 ---- .github/ISSUE_TEMPLATE/2-feature.yml | 49 ++++++ .../package.json | 27 ++++ .../public/index.html | 14 ++ .../mdx-evaluate-create-react-app/src/App.js | 31 ++++ .../src/index.js | 12 ++ sandbox-templates/mdx-evaulate-node/index.js | 17 ++ .../mdx-evaulate-node/package.json | 16 ++ .../mdx-loader-next/next.config.js | 26 ++++ .../mdx-loader-next/package.json | 17 ++ .../mdx-loader-next/pages/index.mdx | 8 + 13 files changed, 362 insertions(+), 72 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/1-bug.md create mode 100644 .github/ISSUE_TEMPLATE/1-bug.yml delete mode 100644 .github/ISSUE_TEMPLATE/2-feature.md create mode 100644 .github/ISSUE_TEMPLATE/2-feature.yml create mode 100644 sandbox-templates/mdx-evaluate-create-react-app/package.json create mode 100644 sandbox-templates/mdx-evaluate-create-react-app/public/index.html create mode 100644 sandbox-templates/mdx-evaluate-create-react-app/src/App.js create mode 100644 sandbox-templates/mdx-evaluate-create-react-app/src/index.js create mode 100644 sandbox-templates/mdx-evaulate-node/index.js create mode 100644 sandbox-templates/mdx-evaulate-node/package.json create mode 100644 sandbox-templates/mdx-loader-next/next.config.js create mode 100644 sandbox-templates/mdx-loader-next/package.json create mode 100644 sandbox-templates/mdx-loader-next/pages/index.mdx diff --git a/.github/ISSUE_TEMPLATE/1-bug.md b/.github/ISSUE_TEMPLATE/1-bug.md deleted file mode 100644 index 472460f..0000000 --- a/.github/ISSUE_TEMPLATE/1-bug.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -name: 🐛 Bug report -about: Create a report to help us improve -labels: 🔍 status/open, 🐛 type/bug ---- - - - -### Subject of the issue - -Describe your issue here. - -This is *not* a place to ask questions. For that, go to [Discussions](https://github.com/mdx-js/mdx/discussions) - -### Your environment - -* **OS**: -* **Packages**: -* **Env**: - -### Steps to reproduce - -Tell us how to reproduce this issue. Please provide a working and simplified example. - -🎉 BONUS POINTS for creating a [minimal reproduction](https://stackoverflow.com/help/mcve) and uploading it to GitHub. This will get you the fastest support. 🎉 - -### Expected behaviour - -What should happen? - -### Actual behaviour - -What happens instead? diff --git a/.github/ISSUE_TEMPLATE/1-bug.yml b/.github/ISSUE_TEMPLATE/1-bug.yml new file mode 100644 index 0000000..4f2fde5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/1-bug.yml @@ -0,0 +1,145 @@ +name: 🐛 Bug report +description: Describe a problem + +body: + - type: markdown + attributes: + value: | + Some general tips: + + - Is this really a problem? + - Is this a problem here? + - Can this be solved in a different way? + + - type: checkboxes + id: initial-checklist + attributes: + label: Initial checklist + options: + - label: I read the [support docs](https://mdxjs.com/support) + required: true + - label: I read the [contributing guide](https://mdxjs.com/contributing) + required: true + - label: I agree to follow the [code of conduct](https://github.com/mdx-js/.github/blob/HEAD/code-of-conduct.md) + required: true + - label: I searched [issues](https://github.com/search?q=user%3Amdx-js&type=Issues) and couldn’t find anything (or linked relevant results below) + required: true + + - type: input + id: affected-versions + attributes: + label: Affected packages and versions + description: Please test using the latest version of the relevant packages to make sure your issue has not already been fixed. + validations: + required: true + + - type: input + id: runnable-example + attributes: + label: Link to runnable example + description: | + Link to repository or sandbox with runnable example of the issue. + + Some CodeSandbox starters: + - [MDX Loader with Next.js](https://codesandbox.io/s/github/mdx-js/.github/sandbox-templates/mdx-loader-next) + - [MDX Evaluate with Node.js](https://codesandbox.io/s/github/mdx-js/.github/sandbox-templates/mdx-evaulate-node) + - [MDX Evaluate with Create React App](https://codesandbox.io/s/github/mdx-js/.github/sandbox-templates/mdx-evaluate-create-react-app) + + Alternatively, use the next section *Steps to reproduce*. + validations: + required: false + + - type: textarea + id: steps-to-reproduce + attributes: + label: Steps to reproduce + description: How did this happen? Please provide a [minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). + validations: + required: true + + - type: textarea + id: expected-behavior + attributes: + label: Expected behavior + description: What should happen? + validations: + required: true + + - type: textarea + id: actual-behavior + attributes: + label: Actual behavior + description: What happens instead? + validations: + required: true + + - type: dropdown + id: javascript-runtime + attributes: + label: Runtime + description: | + What JavaScript runtime are you using to build or run the code? + **Note**: for ECMASCript modules (ESM) in Node, at minimum Node.js 12.20, 14.14, or 16.0 is required. + multiple: true + options: + - Node v17 + - Node v16 + - Node v14 + - Node v12 + - Deno + - Electron + - Other (please specify in steps to reproduce) + validations: + required: false + + - type: dropdown + id: package-manager + attributes: + label: Package manager + description: What package manager are you using? + multiple: true + options: + - npm v8 + - npm v6 + - yarn v2 + - yarn v1 + - pnpm + - Other (please specify in steps to reproduce) + validations: + required: false + + - type: dropdown + id: operating-system + attributes: + label: OS + description: What operating system are you using? + multiple: true + options: + - Windows + - Linux + - macOS + - Other (please specify in steps to reproduce) + validations: + required: false + + - type: dropdown + id: build-tools + attributes: + label: Build and bundle tools + description: What, if any, tools are used to build or bundle the project? + multiple: true + options: + - webpack + - Rollup + - esbuild + - Parcel + - Create React App + - Gatsby + - Next.js + - Remix + - Docusaurus + - Snowpack + - Vite + - Other (please specify in steps to reproduce) + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/2-feature.md b/.github/ISSUE_TEMPLATE/2-feature.md deleted file mode 100644 index 695ca70..0000000 --- a/.github/ISSUE_TEMPLATE/2-feature.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -name: 🚀 Feature request -about: Suggest an idea for this project -labels: 🔍 status/open, 🦋 type/enhancement ---- - - - -### Subject of the feature - -Describe your issue here. - -### Problem - -If the feature requests relates to a problem, please describe the problem you are trying to solve here. - -### Expected behavior - -What should happen? Please describe the desired behavior. - -### Alternatives - -What are the alternative solutions? Please describe what else you have considered? diff --git a/.github/ISSUE_TEMPLATE/2-feature.yml b/.github/ISSUE_TEMPLATE/2-feature.yml new file mode 100644 index 0000000..e3017f6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/2-feature.yml @@ -0,0 +1,49 @@ +name: 🚀 Feature request +description: Suggest an idea + +body: + - type: markdown + attributes: + value: | + Some general tips: + + - Is this really a problem? + - Is this a problem here? + + - type: checkboxes + id: initial-checklist + attributes: + label: Initial checklist + options: + - label: I read the [support docs](https://mdxjs.com/support) + required: true + - label: I read the [contributing guide](https://mdxjs.com/contributing) + required: true + - label: I agree to follow the [code of conduct](https://github.com/mdx-js/.github/blob/HEAD/code-of-conduct.md) + required: true + - label: I searched [issues](https://github.com/search?q=user%3Amdx-js&type=Issues) and couldn’t find anything (or linked relevant results below) + required: true + + - type: textarea + id: problem + attributes: + label: Problem + description: Please describe the problem you are trying to solve here. + validations: + required: true + + - type: textarea + id: solution + attributes: + label: Solution + description: What should happen? Please describe the desired behavior. + validations: + required: true + + - type: textarea + id: alternatives + attributes: + label: Alternatives + description: What are the alternative solutions? Can this be solved in a different way? + validations: + required: true diff --git a/sandbox-templates/mdx-evaluate-create-react-app/package.json b/sandbox-templates/mdx-evaluate-create-react-app/package.json new file mode 100644 index 0000000..2dbb4f2 --- /dev/null +++ b/sandbox-templates/mdx-evaluate-create-react-app/package.json @@ -0,0 +1,27 @@ +{ + "name": "mdx-evaluate-create-react-app", + "version": "1.0.0", + "license": "MIT", + "private": true, + "dependencies": { + "@mdx-js/mdx": "2.0.0-rc.2", + "react": "17.0.2", + "react-dom": "17.0.2", + "react-scripts": "5.0.0-next.47" + }, + "devDependencies": { + "@babel/runtime": "7.13.8", + "typescript": "4.1.3" + }, + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test --env=jsdom" + }, + "browserslist": [ + ">0.2%", + "not dead", + "not ie <= 11", + "not op_mini all" + ] +} diff --git a/sandbox-templates/mdx-evaluate-create-react-app/public/index.html b/sandbox-templates/mdx-evaluate-create-react-app/public/index.html new file mode 100644 index 0000000..6ee2e79 --- /dev/null +++ b/sandbox-templates/mdx-evaluate-create-react-app/public/index.html @@ -0,0 +1,14 @@ + + + + + + MDX + CRA + + + +
+ + diff --git a/sandbox-templates/mdx-evaluate-create-react-app/src/App.js b/sandbox-templates/mdx-evaluate-create-react-app/src/App.js new file mode 100644 index 0000000..da534d7 --- /dev/null +++ b/sandbox-templates/mdx-evaluate-create-react-app/src/App.js @@ -0,0 +1,31 @@ +// ⚠️ Important! Please make sure the dependencies are up to date. +// You can refresh them in the Dependencies section (left-bottom on CodeSandbox) + +import { useEffect, useState } from "react"; +import * as runtime from "react/jsx-runtime"; +import { evaluate } from "@mdx-js/mdx"; + +const mdxContent = ` +export const planet = 'World' + +# Hello, {planet}! + +* list +* item +`; + +function useMDX(content) { + const [exports, setExports] = useState({ default: runtime.Fragment }); + + useEffect(() => { + evaluate(mdxContent, { ...runtime }).then((exports) => setExports(exports)); + }, [content]); + + return exports; +} + +export default function App() { + const exports = useMDX(mdxContent); + const Content = exports.default; + return ; +} diff --git a/sandbox-templates/mdx-evaluate-create-react-app/src/index.js b/sandbox-templates/mdx-evaluate-create-react-app/src/index.js new file mode 100644 index 0000000..75c48a1 --- /dev/null +++ b/sandbox-templates/mdx-evaluate-create-react-app/src/index.js @@ -0,0 +1,12 @@ +import { StrictMode } from "react"; +import ReactDOM from "react-dom"; + +import App from "./App.js"; + +const rootElement = document.getElementById("root"); +ReactDOM.render( + + + , + rootElement +); diff --git a/sandbox-templates/mdx-evaulate-node/index.js b/sandbox-templates/mdx-evaulate-node/index.js new file mode 100644 index 0000000..86d131f --- /dev/null +++ b/sandbox-templates/mdx-evaulate-node/index.js @@ -0,0 +1,17 @@ +// ⚠️ Important! Please make sure the dependencies are up to date. +// You can refresh them in the Dependencies section (left-bottom on CodeSandbox) + +import http from "node:http"; +import * as runtime from "react/jsx-runtime.js"; +import ReactDom from "react-dom/server.js"; +import { evaluate } from "@mdx-js/mdx"; + +// Note: refresh the pane on the right to see changes. + +http + .createServer(async function (_, res) { + const content = "Hi there!"; + const { default: Content } = await evaluate(content, runtime); + ReactDom.renderToNodeStream(Content()).pipe(res); + }) + .listen(8080); diff --git a/sandbox-templates/mdx-evaulate-node/package.json b/sandbox-templates/mdx-evaulate-node/package.json new file mode 100644 index 0000000..5aba233 --- /dev/null +++ b/sandbox-templates/mdx-evaulate-node/package.json @@ -0,0 +1,16 @@ +{ + "name": "node-http-server", + "version": "1.0.0", + "license": "MIT", + "private": true, + "type": "module", + "scripts": { + "start": "nodemon index.js" + }, + "dependencies": { + "@mdx-js/mdx": "2.0.0-rc.2", + "nodemon": "2.0.15", + "react": "17.0.2", + "react-dom": "17.0.2" + } +} diff --git a/sandbox-templates/mdx-loader-next/next.config.js b/sandbox-templates/mdx-loader-next/next.config.js new file mode 100644 index 0000000..2b6fb4f --- /dev/null +++ b/sandbox-templates/mdx-loader-next/next.config.js @@ -0,0 +1,26 @@ +// ⚠️ Important! Please make sure the dependencies are up to date. +// You can refresh them in the Dependencies section (left-bottom on CodeSandbox) + +module.exports = { + // Support MDX files as pages: + pageExtensions: ["md", "mdx", "tsx", "ts", "jsx", "js"], + // Support loading `.md`, `.mdx`: + webpack(config, options) { + config.module.rules.push({ + test: /\.mdx?$/, + use: [ + // The default `babel-loader` used by Next: + options.defaultLoaders.babel, + { + loader: "@mdx-js/loader", + /** @type {import('@mdx-js/loader').Options} */ + options: { + /* jsxImportSource: …, otherOptions… */ + }, + }, + ], + }); + + return config; + }, +}; diff --git a/sandbox-templates/mdx-loader-next/package.json b/sandbox-templates/mdx-loader-next/package.json new file mode 100644 index 0000000..a6f6ff5 --- /dev/null +++ b/sandbox-templates/mdx-loader-next/package.json @@ -0,0 +1,17 @@ +{ + "name": "mdx-loader-next", + "version": "1.0.0", + "license": "MIT", + "private": true, + "scripts": { + "dev": "next", + "build": "next build", + "start": "next start" + }, + "dependencies": { + "@mdx-js/loader": "2.0.0-rc.2", + "next": "12.0.4", + "react": "17.0.2", + "react-dom": "17.0.2" + } +} diff --git a/sandbox-templates/mdx-loader-next/pages/index.mdx b/sandbox-templates/mdx-loader-next/pages/index.mdx new file mode 100644 index 0000000..20a63ba --- /dev/null +++ b/sandbox-templates/mdx-loader-next/pages/index.mdx @@ -0,0 +1,8 @@ +export const planet = 'World' + +# Hello, {planet}! + +
+ * list + * items +