-
Notifications
You must be signed in to change notification settings - Fork 317
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
Use aws-amplify/docs as foundation #75
Changes from all commits
7afe526
c513130
5b865d1
73d5826
bd7494c
cbc15c9
bc2e631
e9e704e
c3d0f1b
7158581
63840be
13c7ada
5bd7899
a1899fa
0a587e1
a828ce3
ff7e2e4
e15adde
260bb72
b55cbe4
6493fb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,75 @@ | ||
const { execSync } = require("child_process"); | ||
const path = require("path"); | ||
|
||
const BRANCH = execSync("git rev-parse --abbrev-ref HEAD") | ||
const gitHead = execSync("git rev-parse --abbrev-ref HEAD") | ||
.toString() | ||
.trim(); | ||
|
||
const BRANCH = gitHead === "HEAD" ? "main" : gitHead; | ||
|
||
const withNextPluginPreval = require("next-plugin-preval/config")(); | ||
const withCompileNodeModules = require("@moxy/next-compile-node-modules")({ | ||
include: /[\\/]packages[\\/]/, | ||
include: [ | ||
// Using `path.dirname` because `package.json#main` doesn't exist in some packages yet | ||
path.dirname(require.resolve("@aws-amplify/ui-core/package.json")), | ||
path.dirname(require.resolve("@aws-amplify/ui-react/package.json")), | ||
path.dirname(require.resolve("amplify-docs/package.json")), | ||
], | ||
test: /\.(js|ts)x?/, | ||
}); | ||
|
||
const withMDX = require("@next/mdx")({ extension: /\.mdx?$/ }); | ||
module.exports = withNextPluginPreval( | ||
withCompileNodeModules({ | ||
env: { BRANCH }, | ||
pageExtensions: ["mdx", "page.tsx"], | ||
// Convenience for local development, since / will 404 by default | ||
redirects() { | ||
return [ | ||
{ | ||
source: "/", | ||
destination: "/ui", | ||
permanent: true, | ||
}, | ||
]; | ||
}, | ||
// ! This exists due to the TypeScript issues in amplify-docs | ||
typescript: { | ||
ignoreBuildErrors: true, | ||
}, | ||
webpack(config) { | ||
// https://github.com/wooorm/xdm#next | ||
config.module.rules.push({ | ||
test: /\.mdx$/, | ||
use: [ | ||
{ | ||
loader: "xdm/webpack.cjs", | ||
options: { | ||
rehypePlugins: [require("mdx-prism")], | ||
remarkPlugins: [ | ||
require("remark-gfm"), | ||
require("remark-mdx-images"), | ||
[ | ||
require("remark-github"), | ||
{ | ||
repository: "aws-amplify/docs", | ||
}, | ||
], | ||
// Remove frontmatter from MDX | ||
require("remark-frontmatter"), | ||
// Extract to `frontmatter` export | ||
[ | ||
require("remark-mdx-frontmatter").remarkMdxFrontmatter, | ||
{ name: "frontmatter" }, | ||
], | ||
require("amplify-docs/src/plugins/headings.tsx"), | ||
require("./src/plugins/remark-layout"), | ||
], | ||
}, | ||
}, | ||
], | ||
}); | ||
|
||
module.exports = withCompileNodeModules( | ||
withMDX({ | ||
env: { | ||
BRANCH, | ||
return config; | ||
}, | ||
pageExtensions: ["js", "jsx", "mdx", "tsx"], | ||
}) | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
"name": "docs", | ||
"version": "0.0.1", | ||
"scripts": { | ||
"dev": "PORT=5000 next-remote-watch 'src/content' '../packages/e2e/**/*.feature'", | ||
"dev": "next dev -p 5000", | ||
"build": "next build && next export", | ||
"start": "next start", | ||
"test": "$_ run build" | ||
|
@@ -17,27 +17,26 @@ | |
"@mdx-js/loader": "^1.5.1", | ||
"@mdx-js/react": "^1.6.18", | ||
"@moxy/next-compile-node-modules": "^2.1.1", | ||
"@next/mdx": "^9.1.1", | ||
"@xstate/inspect": "^0.4.1", | ||
"amplify-docs": "github:https://github.com/aws-amplify/docs#33d383d", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Including https://github.com/aws-amplify/docs as a dependency is buggy with yarn. The best way I've found was to not use Let me know if you can install & run this locally, or if you run into issues. I had to do |
||
"aws-amplify": "latest", | ||
"aws-amplify-react": "latest", | ||
"gray-matter": "^4.0.3", | ||
"mdx-prism": "^0.3.3", | ||
"next": "latest", | ||
"next-mdx-remote": "^3.0.2", | ||
"prism-react-renderer": "^1.2.0", | ||
"next-plugin-preval": "^1.2.1", | ||
"prism-theme-night-owl": "^1.4.0", | ||
"raw-loader": "^4.0.2", | ||
"react": "latest", | ||
"react-dom": "latest", | ||
"react-smooshpack": "^1.0.0-alpha-31", | ||
"rehype": "^11.0.0", | ||
"remark-autolink-headings": "^6.0.1", | ||
"remark-code-titles": "^0.1.2", | ||
"remark-frontmatter": "^3.0.0", | ||
"remark-gfm": "^1.0.0", | ||
"remark-highlight.js": "^6.0.0", | ||
"remark-github": "^10.1.0", | ||
"remark-mdx-frontmatter": "^1.0.1", | ||
"remark-mdx-images": "^1.0.2", | ||
"remark-slug": "^6.0.0" | ||
"xdm": "^1.12.0" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
|
@@ -46,7 +45,6 @@ | |
"@types/node": "^14.14.31", | ||
"@types/react": "^17.0.2", | ||
"autoprefixer": "^10.2.4", | ||
"next-remote-watch": "^1.0.0", | ||
"postcss": "^8.2.6", | ||
"tailwindcss": "^2.0.3", | ||
"typescript": "^4.2.2" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../node_modules/amplify-docs/docs/assets |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../node_modules/amplify-docs/docs/scripts |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No more
next-remote-watch
because no morenext-mdx-remote