Update nextjs version, fix lib/data script, lint-staged

This commit is contained in:
kitajchuk
2022-05-02 09:12:06 -07:00
parent 648135b7c5
commit 7a50c21960
13 changed files with 399 additions and 1288 deletions

View File

@@ -1,25 +0,0 @@
{
"presets": [
"next/babel"
],
"plugins": [
[
"prismjs",
{
"languages": [
"javascript",
"js",
"json",
"bash",
"http"
],
"plugins": [
"line-numbers",
"show-language"
],
"theme": "okaidia",
"css": true
}
]
]
}

View File

@@ -1,5 +0,0 @@
**/node_modules/*
**/out/*
**/.next/*
next.config.js
**/cypress/*

View File

@@ -1,45 +0,0 @@
{
"settings": {
"react": {
"version": "detect"
}
},
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"react-app"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
"react/prop-types": "off",
"react/react-in-jsx-scope": "off",
"jsx-a11y/anchor-is-valid": "off",
"jsx-a11y/alt-text": "off",
"indent": [
"error",
2
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
}

View File

@@ -1,4 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn lint-staged
yarn build

View File

@@ -31,19 +31,6 @@ export function getData(key) {
};
}
/**
* Get a cleaned slug for Next.js static paths pattern
* @param {string} scope The subdirectory of ./markdown
* @param {string} slug The fileName of a found markdown file
* @returns {Array}
*/
function _getCleanSlug(scope, slug) {
return slug
.replace(path.join(markdownDir, scope), '')
.replace(/^\/+|\/+$/, '')
.split('/');
}
/**
* Load Markdown and YAML front-matter to generate the static props for Next.js docs component
* @param {string} filePath The full path to a markdown file
@@ -89,12 +76,9 @@ function _getMarkdownPaths(dirPath, scope, arrayOfFiles = [{params:{slug:[]}}])
const isIndexFile = fs.existsSync(indexFile);
if (isIndexFile) {
slug = _getCleanSlug(scope, path.join(
__dirname,
dirPath,
'/',
file
));
slug = [
file,
];
arrayOfFiles.push({
params: {
@@ -106,12 +90,11 @@ function _getMarkdownPaths(dirPath, scope, arrayOfFiles = [{params:{slug:[]}}])
arrayOfFiles = _getMarkdownPaths(filePath, scope, arrayOfFiles);
} else if (isMarkdown) {
slug = _getCleanSlug(scope, path.join(
__dirname,
dirPath,
'/',
file.replace(/\.md$/, '')
));
slug = filePath
.replace(path.join(markdownDir, scope), '')
.replace(/\.md$/, '')
.replace(/^\/+|\/+$/, '')
.split('/');
arrayOfFiles.push({
params: {

View File

@@ -1,15 +1,3 @@
module.exports = {
trailingSlash: true,
webpack: (config, { dev, isServer }) => {
// Replace React with Preact only for client
if (!isServer) {
Object.assign(config.resolve.alias, {
react: 'preact/compat',
'react-dom/test-utils': 'preact/test-utils',
'react-dom': 'preact/compat',
});
}
return config;
},
};

View File

@@ -7,7 +7,6 @@
"prepare": "husky install",
"dev": "next",
"start": "next start",
"prebuild": "yarn lint",
"build": "next build",
"export": "next export",
"pretest": "node cypress/scripts/fixtures.js",
@@ -20,8 +19,7 @@
"dependencies": {
"classnames": "^2.2.6",
"nanoid": "^3.1.22",
"next": "^10.0.8-canary.9",
"preact": "^10.5.13",
"next": "^12.1.4",
"prismjs": "^1.23.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
@@ -41,10 +39,91 @@
"eslint-plugin-react-hooks": "^4.2.0",
"gray-matter": "^4.0.2",
"husky": "^6.0.0",
"lint-staged": "^12.4.1",
"remark": "^13.0.0",
"remark-gfm": "^1.0.0",
"remark-html": "^13.0.1",
"sass": "^1.32.8",
"yamljs": "^0.3.0"
},
"lint-staged": {
"*.js": "yarn lint"
},
"eslintConfig": {
"settings": {
"react": {
"version": "detect"
}
},
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"react-app"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
"react/prop-types": "off",
"react/react-in-jsx-scope": "off",
"jsx-a11y/anchor-is-valid": "off",
"jsx-a11y/alt-text": "off",
"indent": [
"error",
2
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
},
"ignorePatterns": [
"**/node_modules/*",
"**/out/*",
"**/.next/*",
"next.config.js",
"**/cypress/*"
]
},
"babel": {
"presets": [
"next/babel"
],
"plugins": [
[
"prismjs",
{
"languages": [
"javascript",
"js",
"json",
"bash",
"http"
],
"plugins": [
"line-numbers",
"show-language"
],
"theme": "okaidia",
"css": true
}
]
]
}
}

View File

@@ -18,7 +18,7 @@ export async function getStaticProps() {
const data = getData('privacy');
// Use the new public method in a more ad hoc manner like this...
const parsed = await getParsedMarkdown(path.join(process.cwd(), 'pages', 'privacy.md'));
const parsed = await getParsedMarkdown(path.join(process.cwd(), 'markdown', 'privacy.md'));
return {
props: {

View File

@@ -18,7 +18,7 @@ export async function getStaticProps() {
const data = getData('terms');
// Use the new public method in a more ad hoc manner like this...
const parsed = await getParsedMarkdown(path.join(process.cwd(), 'pages', 'terms.md'));
const parsed = await getParsedMarkdown(path.join(process.cwd(), 'markdown', 'terms.md'));
return {
props: {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 48 KiB

1477
yarn.lock

File diff suppressed because it is too large Load Diff