Skip to content

Commit

Permalink
feat: upgrade nextjs
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <tukon479@gmail.com>
  • Loading branch information
Innei committed Nov 3, 2024
1 parent 352d020 commit 9e64865
Show file tree
Hide file tree
Showing 88 changed files with 4,484 additions and 4,040 deletions.
15 changes: 0 additions & 15 deletions .eslintrc.cjs

This file was deleted.

57 changes: 57 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// @ts-check
import { defineConfig } from 'eslint-config-hyoban'

export default defineConfig(
{
formatting: false,
lessOpinionated: true,
ignores: [],
preferESM: false,
react: 'next',
tailwindCSS: true,
},
{
settings: {
tailwindcss: {
whitelist: ['center'],
},
},
rules: {
'package-json/valid-package-def': 'off',
'@eslint-react/no-missing-key': 'warn',
'no-restricted-syntax': 'off',
'import/no-anonymous-default-export': 'off',
eqeqeq: 'warn',
'no-console': 'warn',
'@eslint-react/dom/no-missing-button-type': 0,
'unicorn/prefer-math-trunc': 'off',
'unicorn/prefer-dom-node-remove': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'no-empty': 'off',
'@typescript-eslint/no-empty-object-type': 'warn',
'unicorn/prefer-query-selector': 0,
'regexp/no-super-linear-backtracking': 0,
'regexp/no-useless-assertions': 0,
'unicorn/no-new-array': 0,
'@typescript-eslint/method-signature-style': 0,
'unicorn/prefer-code-point': 'warn',
'unicorn/no-object-as-default-parameter': 'warn',
'unused-imports/no-unused-vars': 'warn',
'@eslint-react/no-unstable-default-props': 'warn',
'unicorn/prefer-regexp-test': 'warn',
'no-unsafe-optional-chaining': 'warn',
'unicorn/prefer-logical-operator-over-ternary': 'warn',
'arrow-body-style': 0,
'unicorn/no-array-callback-reference': 0,
'prefer-regex-literals': 0,
'regexp/optimal-quantifier-concatenation': 'warn',
'unicorn/prefer-string-slice': 0,
'array-callback-return': 0,
'regexp/no-unused-capturing-group': 1,
'unicorn/no-anonymous-default-export': 0,
'unicorn/no-magic-array-flat-depth': 1,
'react-refresh/only-export-components': 0,
'@eslint-react/no-clone-element': 0,
},
},
)
1 change: 0 additions & 1 deletion markdown/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
{
"paths": [
"custom-component.md",
"draw.md",
"highlight.md",
"markdown.md"
],
Expand Down
27 changes: 0 additions & 27 deletions markdown/sections/usage/draw.md

This file was deleted.

8 changes: 6 additions & 2 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { bootstarp } from './plugins/json-watcher.mjs'

bootstarp()
if (process.env.NODE_ENV === 'development') {
bootstarp()
}

/** @type {import('next').NextConfig} */
const nextConfig = {
output: process.env.NODE_ENV === 'production' ? 'export' : 'standalone',

eslint: {
ignoreDuringBuilds: true,
},
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
config.plugins.push(
new webpack.optimize.MinChunkSizePlugin({
Expand Down
109 changes: 55 additions & 54 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,97 +1,98 @@
{
"name": "book-ssg-template",
"repository": {
"url": "/~https://github.com/Innei/book-ssg-template"
},
"version": "0.1.0",
"private": true,
"packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee",
"license": "MIT",
"repository": {
"url": "/~https://github.com/Innei/book-ssg-template"
},
"scripts": {
"prepare": "pnpm exec simple-git-hooks",
"dev": "next dev -p 9988",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"bump": {
"before": [
"git pull --rebase",
"ni"
],
"changelog": true
},
"simple-git-hooks": {
"pre-commit": "pnpm exec lint-staged"
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
"eslint --cache --fix",
"prettier --ignore-path ./.gitignore --write "
]
"dev": "next dev -p 9988",
"lint": "eslint --fix",
"prepare": "pnpm exec simple-git-hooks",
"start": "next start"
},
"dependencies": {
"@codesandbox/sandpack-react": "2.18.3",
"@excalidraw/excalidraw": "0.17.6",
"@floating-ui/react-dom": "2.1.1",
"@radix-ui/react-dialog": "1.1.1",
"@radix-ui/react-tabs": "1.1.0",
"@codesandbox/sandpack-react": "2.19.9",
"@floating-ui/react-dom": "2.1.2",
"@radix-ui/react-dialog": "1.1.2",
"@radix-ui/react-tabs": "1.1.1",
"@types/katex": "0.16.7",
"camelcase-keys": "9.1.3",
"chokidar": "^3.6.0",
"chokidar": "^4.0.1",
"clsx": "2.1.1",
"colorjs.io": "0.5.2",
"devtools-detector": "2.0.22",
"foxact": "0.2.38",
"framer-motion": "11.3.31",
"foxact": "0.2.41",
"framer-motion": "11.11.11",
"globby": "^14.0.2",
"immer": "10.1.1",
"jotai": "2.9.3",
"jotai": "2.10.1",
"js-yaml": "4.1.0",
"katex": "0.16.11",
"lodash": "4.17.21",
"markdown-to-jsx": "npm:@innei/markdown-to-jsx@7.2.1-beta.6",
"medium-zoom": "1.1.0",
"mermaid": "10.9.1",
"next": "14.2.9",
"next-seo": "6.5.0",
"mermaid": "11.4.0",
"next": "15.0.2",
"next-seo": "6.6.0",
"next-themes": "0.3.0",
"rc-modal-sheet": "0.3.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"rc-modal-sheet": "0.3.2",
"react": "19.0.0-rc-7c8e5e7a-20241101",
"react-dom": "19.0.0-rc-7c8e5e7a-20241101",
"react-intersection-observer": "9.13.1",
"remark": "15.0.1",
"remark-parse": "11.0.0",
"shiki": "1.13.0",
"shiki": "1.22.2",
"swr": "2.2.5",
"tailwind-merge": "2.5.2",
"tailwind-merge": "2.5.4",
"unified": "11.0.5",
"unist-util-visit": "5.0.0",
"vaul": "0.9.2"
"vaul": "1.1.1"
},
"devDependencies": {
"@iconify-json/mingcute": "1.1.20",
"@iconify-json/mingcute": "1.2.1",
"@iconify/tailwind": "1.1.3",
"@innei/eslint-config-react-ts": "0.15.0",
"@innei/prettier": "0.15.0",
"@shikijs/transformers": "1.13.0",
"@shikijs/transformers": "1.22.2",
"@tailwindcss/typography": "0.5.15",
"@types/js-yaml": "4.0.9",
"@types/node": "^20.15.0",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3.0",
"@types/node": "^22.8.7",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"autoprefixer": "^10.4.20",
"daisyui": "4.12.10",
"eslint": "8.57.0",
"daisyui": "4.12.14",
"eslint": "9.14.0",
"eslint-config-hyoban": "3.1.12",
"lint-staged": "15.2.10",
"postcss-import": "16.1.0",
"postcss-nested": "6.2.0",
"postcss-preset-env": "9.6.0",
"postcss-nested": "7.0.2",
"postcss-preset-env": "10.0.9",
"postcss-prune-var": "1.1.2",
"prettier": "3.3.3",
"rimraf": "5.0.10",
"rimraf": "6.0.1",
"simple-git-hooks": "2.11.1",
"tailwind-scrollbar": "3.1.0",
"tailwind-variants": "0.2.1",
"tailwindcss": "^3.4.10",
"typescript": "5.5.4"
"tailwindcss": "^3.4.14",
"typescript": "5.6.3"
},
"simple-git-hooks": {
"pre-commit": "pnpm exec lint-staged"
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
"eslint --fix",
"prettier --ignore-path ./.gitignore --write "
]
},
"bump": {
"before": [
"git pull --rebase",
"ni"
],
"changelog": true
}
}
21 changes: 10 additions & 11 deletions plugins/json-watcher.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { existsSync, writeFileSync } from 'fs'
import { readFile } from 'fs/promises'
import path from 'path'
import { fileURLToPath } from 'url'
/* eslint-disable unicorn/no-this-assignment */
import { existsSync, writeFileSync } from 'node:fs'
import { readFile } from 'node:fs/promises'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { watch } from 'chokidar'
import { globbySync } from 'globby'

const __dirname = path.resolve(fileURLToPath(import.meta.url), '..')
const dataJsonPath = path.resolve(__dirname, '../markdown/index.json')
const workdirPath = path.resolve(__dirname, '../markdown/sections')
const pathGlob = workdirPath + '/**/*.md'
const pathGlob = `${workdirPath}/**/*.md`

const readFsDataJsonData = async () => {
const hasFile = existsSync(dataJsonPath)
Expand Down Expand Up @@ -56,7 +57,7 @@ export async function bootstarp() {
const fsJsonData = await readFsDataJsonData()

const diffData = compareFsTreeWithExistJsonData(parseFsData(fsJsonData))
console.log('diff', diffData)

writeFileSync(
dataJsonPath,
JSON.stringify(patchDataJson(diffData, fsJsonData), null, 2),
Expand Down Expand Up @@ -108,10 +109,8 @@ function patchDataJson(diffData, fsJsonData) {
if (!slugifyJsonMap[slug]) continue

paths.forEach((path) => {
const index = slugifyJsonMap[slug].paths.findIndex(
(_path) => path === _path,
)
if (index > -1) {
const index = slugifyJsonMap[slug].paths.indexOf(path)
if (index !== -1) {
slugifyJsonMap[slug].paths.splice(index, 1)
}
})
Expand Down Expand Up @@ -225,7 +224,7 @@ function debounce(fn, wait) {
let args = arguments

clearTimeout(timerId)
timerId = setTimeout(function () {
timerId = setTimeout(() => {
callback.apply(context, args)
}, wait)
}
Expand Down
Loading

0 comments on commit 9e64865

Please sign in to comment.