Skip to content

Commit 4d68c1c

Browse files
committed
WIP: nextra-theme-docs customize
1 parent c299410 commit 4d68c1c

35 files changed

+2976
-135
lines changed

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
pnpm lint-staged
4+
# pnpm lint-staged

apps/book-web/.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "next/core-web-vitals"
3+
}

apps/book-web/.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
.yarn/install-state.gz
8+
9+
# testing
10+
/coverage
11+
12+
# next.js
13+
/.next/
14+
/out/
15+
16+
# production
17+
/build
18+
19+
# misc
20+
.DS_Store
21+
*.pem
22+
23+
# debug
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
28+
# local env files
29+
.env*.local
30+
31+
# vercel
32+
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo
36+
next-env.d.ts

apps/book-web/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
# or
14+
bun dev
15+
```
16+
17+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18+
19+
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
20+
21+
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.
22+
23+
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
24+
25+
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
26+
27+
## Learn More
28+
29+
To learn more about Next.js, take a look at the following resources:
30+
31+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
32+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
33+
34+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
35+
36+
## Deploy on Vercel
37+
38+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
39+
40+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

apps/book-web/next.config.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import nextra from 'nextra'
2+
3+
const withNextra = nextra({
4+
theme: 'nextra-theme-docs',
5+
themeConfig: './theme.config.tsx',
6+
latex: true,
7+
flexsearch: {
8+
codeblocks: true,
9+
},
10+
defaultShowCopyCode: true,
11+
})
12+
13+
/** @type {import('next').NextConfig} */
14+
const nextConfig = {
15+
reactStrictMode: true,
16+
swcMinify: true,
17+
webpack: (config) => {
18+
config.resolve.fallback = {
19+
fs: false,
20+
}
21+
},
22+
}
23+
24+
export default withNextra(nextConfig)

apps/book-web/package.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "book-web",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev",
7+
"build": "next build",
8+
"start": "next start",
9+
"lint": "next lint"
10+
},
11+
"dependencies": {
12+
"@packages/nextra-theme-docs": "workspace:*",
13+
"next": "14.2.3",
14+
"nextra": "^2.13.4",
15+
"nextra-theme-docs": "^2.13.4",
16+
"react": "^18",
17+
"react-dom": "^18"
18+
},
19+
"devDependencies": {
20+
"@types/node": "^20",
21+
"@types/react": "^18",
22+
"@types/react-dom": "^18",
23+
"eslint": "^8",
24+
"eslint-config-next": "14.2.3",
25+
"postcss": "^8",
26+
"tailwindcss": "^3.4.1",
27+
"typescript": "^5"
28+
}
29+
}

apps/book-web/postcss.config.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import('postcss-load-config').Config} */
2+
const config = {
3+
plugins: {
4+
tailwindcss: {},
5+
},
6+
};
7+
8+
export default config;

apps/book-web/public/favicon.ico

25.3 KB
Binary file not shown.

apps/book-web/public/next.svg

Lines changed: 1 addition & 0 deletions
Loading

apps/book-web/public/vercel.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import * as context from './context'
2+
import NextraDocLayout, { useInternals } from '@packages/nextra-theme-docs'
3+
4+
type Props = {
5+
children: React.ReactNode
6+
}
7+
8+
// pageOpts: PageOpts
9+
// pageProps: any
10+
// themeConfig: ThemeConfig
11+
// children: ReactNode
12+
13+
function NextraLayout({ children }: Props) {
14+
const { context, Layout } = useInternals()
15+
console.log('cotent', context)
16+
console.log('Layout', Layout)
17+
return (
18+
<NextraDocLayout {...context} pageProps={{}}>
19+
{children}
20+
</NextraDocLayout>
21+
)
22+
}
23+
24+
export default NextraLayout
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
import { useRouter } from 'next/router'
2+
3+
import { DocsThemeConfig, PageMapItem, PageOpts } from '@packages/nextra-theme-docs'
4+
import React from 'react'
5+
6+
export const pageOpts: PageOpts = {
7+
frontMatter: {},
8+
filePath: 'pages/index.mdx',
9+
route: '/',
10+
timestamp: 1712618681000,
11+
pageMap: [
12+
{
13+
kind: 'MdxPage',
14+
name: 'Balanced_client-driven_flexibility_6614ba2e52f87b67fc14427b',
15+
route: '/Balanced_client-driven_flexibility_6614ba2e52f87b67fc14427b',
16+
},
17+
{
18+
kind: 'Meta',
19+
data: {
20+
index: { title: 'Introduction' },
21+
another: { title: 'Another Page' },
22+
advanced: { title: 'Advanced (A Folder)' },
23+
contact: {
24+
title: 'Contact ↗',
25+
type: 'page',
26+
href: 'https://twitter.com/shuding_',
27+
newWindow: true,
28+
},
29+
about: { title: 'About' },
30+
'Balanced_client-driven_flexibility_6614ba2e52f87b67fc14427b': {
31+
title: 'Balanced Client Driven Flexibility 6614ba2e52f87b67fc14427b',
32+
},
33+
},
34+
},
35+
{ kind: 'MdxPage', name: 'about', route: '/about' },
36+
{
37+
kind: 'Folder',
38+
name: 'advanced',
39+
route: '/advanced',
40+
children: [
41+
{
42+
kind: 'Folder',
43+
name: ' hello',
44+
route: '/advanced/ hello',
45+
children: [
46+
{ kind: 'MdxPage', name: 'hi', route: '/advanced/ hello/hi' },
47+
{ kind: 'Meta', data: { hi: { title: 'Hi' } } },
48+
],
49+
},
50+
{ kind: 'MdxPage', name: 'satori', route: '/advanced/satori' },
51+
{ kind: 'Meta', data: { satori: { title: 'Satori' } } },
52+
],
53+
},
54+
{ kind: 'MdxPage', name: 'advanced', route: '/advanced' },
55+
{ kind: 'MdxPage', name: 'another', route: '/another' },
56+
{ kind: 'MdxPage', name: 'index', route: '/' },
57+
],
58+
flexsearch: { codeblocks: true },
59+
title: 'Welcome to Nextra',
60+
headings: [],
61+
}
62+
63+
export const pageMap: PageMapItem[] = [
64+
{
65+
kind: 'MdxPage',
66+
name: 'Balanced_client-driven_flexibility_6614ba2e52f87b67fc14427b',
67+
route: '/Balanced_client-driven_flexibility_6614ba2e52f87b67fc14427b',
68+
},
69+
{
70+
kind: 'Meta',
71+
data: {
72+
index: { title: 'Introduction' },
73+
another: { title: 'Another Page' },
74+
advanced: { title: 'Advanced (A Folder)' },
75+
contact: {
76+
title: 'Contact ↗',
77+
type: 'page',
78+
href: 'https://twitter.com/shuding_',
79+
newWindow: true,
80+
},
81+
about: { title: 'About' },
82+
'Balanced_client-driven_flexibility_6614ba2e52f87b67fc14427b': {
83+
title: 'Balanced Client Driven Flexibility 6614ba2e52f87b67fc14427b',
84+
},
85+
},
86+
},
87+
{ kind: 'MdxPage', name: 'about', route: '/about' },
88+
{
89+
kind: 'Folder',
90+
name: 'advanced',
91+
route: '/advanced',
92+
children: [
93+
{
94+
kind: 'Folder',
95+
name: ' hello',
96+
route: '/advanced/ hello',
97+
children: [
98+
{ kind: 'MdxPage', name: 'hi', route: '/advanced/ hello/hi' },
99+
{ kind: 'Meta', data: { hi: { title: 'Hi' } } },
100+
],
101+
},
102+
{ kind: 'MdxPage', name: 'satori', route: '/advanced/satori' },
103+
{ kind: 'Meta', data: { satori: { title: 'Satori' } } },
104+
],
105+
},
106+
{ kind: 'MdxPage', name: 'advanced', route: '/advanced' },
107+
{ kind: 'MdxPage', name: 'another', route: '/another' },
108+
{ kind: 'MdxPage', name: 'index', route: '/' },
109+
]
110+
111+
export const themeConfig: DocsThemeConfig = {
112+
logo: <span>Learning bunJS is Fun!</span>,
113+
editLink: {
114+
text: '',
115+
},
116+
feedback: {
117+
content: '',
118+
},
119+
footer: {
120+
component: null,
121+
text: '',
122+
},
123+
sidebar: {
124+
titleComponent({ title, type }) {
125+
if (type === 'separator') {
126+
return <span className="cursor-default">{title}</span>
127+
}
128+
return <>{title}</>
129+
},
130+
defaultMenuCollapseLevel: 1,
131+
toggleButton: true,
132+
},
133+
useNextSeoProps() {
134+
const { asPath } = useRouter()
135+
if (asPath !== '/') {
136+
return {
137+
titleTemplate: '%s – Learning bunJS is Fun!',
138+
}
139+
}
140+
},
141+
head: function useHead() {
142+
const title = 'hello world'
143+
return (
144+
<>
145+
<meta name="msapplication-TileColor" content="#fff" />
146+
<meta name="theme-color" content="#fff" />
147+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
148+
<meta httpEquiv="Content-Language" content="en" />
149+
<meta name="description" content="Make beautiful websites with Velog & MDX." />
150+
<meta name="og:description" content="Make beautiful websites with Velog & MDX." />
151+
<meta name="twitter:card" content="summary_large_image" />
152+
<meta name="twitter:site:domain" content="velog.io" />
153+
<meta name="twitter:url" content="velog.io" />
154+
<meta name="og:title" content={title ? title + ' – Velog' : 'Velog'} />
155+
<meta property="og:title" content={title ? title + ' – Velog' : 'Velog'} />
156+
<meta name="apple-mobile-web-app-title" content="Velog" />
157+
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
158+
<link rel="icon" href="/favicon.png" type="image/png" />
159+
<link
160+
rel="icon"
161+
href="/favicon-dark.svg"
162+
type="image/svg+xml"
163+
media="(prefers-color-scheme: dark)"
164+
/>
165+
<link
166+
rel="icon"
167+
href="/favicon-dark.png"
168+
type="image/png"
169+
media="(prefers-color-scheme: dark)"
170+
/>
171+
</>
172+
)
173+
},
174+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './NextraLayout'

apps/book-web/src/pages/_app.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import type { AppProps } from 'next/app'
2+
3+
export default function App({ Component, pageProps }: AppProps) {
4+
return <Component {...pageProps} />
5+
}

apps/book-web/src/pages/_document.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Html, Head, Main, NextScript } from 'next/document'
2+
3+
export default function Document() {
4+
return (
5+
<Html lang="ko">
6+
<Head />
7+
<body>
8+
<Main />
9+
<NextScript />
10+
</body>
11+
</Html>
12+
)
13+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import NextraLayout from '@/layouts/NextraLayout'
2+
3+
const BookEditPage = () => {
4+
return <NextraLayout>hello</NextraLayout>
5+
}
6+
7+
export default BookEditPage

0 commit comments

Comments
 (0)