Skip to content

Commit 1da2b1f

Browse files
authored
docs: init document (#74)
1 parent f47d044 commit 1da2b1f

18 files changed

+2435
-171
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const Component = () => (
7474
)
7575
```
7676

77-
![Avatar Preview](docs/public/avatar-preview.png)
77+
![Avatar Preview](public/avatar-preview.png)
7878

7979
[see the full code](examples/basic/pages/index.tsx)
8080

@@ -110,7 +110,7 @@ const Component = () => (
110110
)
111111
```
112112

113-
![Ocean Theme Preview](docs/public/ocean-theme.png)
113+
![Ocean Theme Preview](public/ocean-theme.png)
114114

115115
### Browser
116116

docs/.gitignore

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
.pnpm-debug.log*
27+
28+
# local env files
29+
.env*.local
30+
31+
# vercel
32+
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo
36+
next-env.d.ts
37+
38+
# nextra
39+
public/feed.xml

docs/README.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Portfolio Starter Kit
2+
3+
This portfolio is built with **Next.js** and a library called [Nextra](https://nextra.vercel.app/). It allows you to write Markdown and focus on the _content_ of your portfolio. This starter includes:
4+
5+
- Automatically configured to handle Markdown/MDX
6+
- Generates an RSS feed based on your posts
7+
- A beautiful theme included out of the box
8+
- Easily categorize posts with tags
9+
- Fast, optimized web font loading
10+
11+
https://demo.vercel.blog
12+
13+
## Configuration
14+
15+
1. Update your name in `theme.config.js` or change the footer.
16+
1. Update your name and site URL for the RSS feed in `scripts/gen-rss.js`.
17+
1. Update the meta tags in `pages/_document.tsx`.
18+
1. Update the posts inside `pages/posts/*.md` with your own content.
19+
20+
## Deploy your own
21+
22+
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) or preview live with [StackBlitz](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/blog)
23+
24+
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com./vercel/next.js/tree/canary/examples/blog&project-name=portfolio&repository-name=portfolio)
25+
26+
## How to use
27+
28+
Execute [`create-next-app`](https://github.com./vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init), [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/), or [pnpm](https://pnpm.io) to bootstrap the example:
29+
30+
```bash
31+
npx create-next-app --example blog my-blog
32+
# or
33+
yarn create next-app --example blog my-blog
34+
# or
35+
pnpm create next-app --example blog my-blog
36+
```
37+
38+
Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).

docs/components/JsonViewerPreview.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { JsonViewer, JsonViewerProps } from '@textea/json-viewer'
2+
import type React from 'react'
3+
4+
export const JsonViewerPreview: React.FC<JsonViewerProps> = (props) => {
5+
return (
6+
<JsonViewer
7+
style={{
8+
fontSize: 12
9+
}}
10+
value={props.value}
11+
/>
12+
)
13+
}
File renamed without changes.

examples/basic/next.config.js renamed to docs/next.config.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
const withNextra = require('nextra')({
2+
theme: 'nextra-theme-docs',
3+
themeConfig: './theme.config.js',
4+
unstable_staticImage: true
5+
})
6+
17
/** @type {import('next').NextConfig} */
28
const nextConfig = {
39
reactStrictMode: true,
@@ -15,4 +21,4 @@ const withTM = require('next-transpile-modules')([], {
1521
debug: false
1622
})
1723

18-
module.exports = withTM(nextConfig)
24+
module.exports = withNextra(withTM(nextConfig))

examples/basic/package.json renamed to docs/package.json

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
{
2-
"name": "@textea/json-viewer-example-basic",
2+
"name": "@textea/json-viewer-docs",
33
"private": true,
44
"scripts": {
5-
"dev": "next dev",
5+
"dev": "next",
66
"build": "next build",
7-
"start": "next start",
8-
"lint": "next lint"
7+
"start": "next start"
98
},
109
"dependencies": {
1110
"@textea/json-viewer": "workspace:^",
12-
"next": "^12.3.0",
11+
"gray-matter": "^4.0.3",
12+
"next": "^12.3.1",
13+
"nextra": "^2.0.0-beta.29",
14+
"nextra-theme-docs": "^2.0.0-beta.29",
1315
"react": "^18.2.0",
1416
"react-dom": "^18.2.0"
1517
},
1618
"devDependencies": {
17-
"@next/eslint-plugin-next": "^12.3.1",
18-
"@textea/dev-kit": "^0.13.4",
19-
"@types/node": "^18.7.18",
20-
"@types/react": "^18.0.20",
19+
"@textea/dev-kit": "^0.13.8",
20+
"@types/node": "^18.7.21",
21+
"@types/react": "^18.0.21",
2122
"@types/react-dom": "^18.0.6",
2223
"next-transpile-modules": "^9.0.0",
2324
"typescript": "^4.8.3"

docs/pages/_app.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import 'nextra-theme-docs/style.css'
2+
3+
import type { AppProps } from 'next/app'
4+
import type React from 'react'
5+
6+
export default function Nextra ({ Component, pageProps }: AppProps) {
7+
return <Component {...pageProps} />
8+
}

examples/basic/pages/index.tsx renamed to docs/pages/full/index.tsx

+1-9
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Image from 'next/image'
1818
import type React from 'react'
1919
import { useCallback, useEffect, useState } from 'react'
2020

21-
import { ocean } from '../shared'
21+
import { ocean } from '../../lib/shared'
2222

2323
const allowedDomains = ['i.imgur.com']
2424

@@ -130,14 +130,6 @@ const IndexPage: React.FC = () => {
130130
>
131131
JSON viewer
132132
</Typography>
133-
<a href='https://www.netlify.com' target='_blank' rel='noreferrer'>
134-
<Image
135-
width={114}
136-
height={51}
137-
src='https://www.netlify.com/v3/img/components/netlify-color-accent.svg'
138-
alt='Deploys by Netlify'
139-
/>
140-
</a>
141133
</Toolbar>
142134
</AppBar>
143135
<Toolbar/>

docs/pages/index.mdx

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import Link from 'next/link'
2+
import Button from '@mui/material/Button'
3+
import { JsonViewerPreview } from '../components/JsonViewerPreview'
4+
5+
# @textea/json-viewer
6+
7+
### NPM
8+
```shell
9+
npm install @textea/json-viewer
10+
```
11+
### Yarn
12+
```shell
13+
yarn add @textea/json-viewer
14+
```
15+
### PNPM
16+
```shell
17+
pnpm add @textea/json-viewer
18+
```
19+
20+
### Basic Example
21+
22+
```tsx
23+
import { JsonViewer } from '@textea/json-viewer'
24+
25+
const object = { /* my json object */ }
26+
const Component = () => (<JsonViewer value={object}/>)
27+
```
28+
29+
<JsonViewerPreview
30+
value={{
31+
string: 'this is a string',
32+
number: 1,
33+
float: 114.514,
34+
bigint: 10086n,
35+
object: {
36+
value: new Date('December 17, 1995 03:24:00')
37+
}
38+
}}
39+
/>
40+
41+
### Full Example
42+
43+
<Link href='/full'>
44+
<Button>
45+
View ->
46+
</Button>
47+
</Link>
48+
49+
## Contributors
50+
51+
<a href="https://github.com./TexteaInc/json-viewer/graphs/contributors"><img src="https://opencollective.com/json-viewer/contributors.svg?width=890&button=false" /></a>
52+
53+
## Acknowledge
54+
55+
This package is originally based on [mac-s-g/react-json-view](https://github.com./mac-s-g/react-json-view).
56+
57+
Also thanks open source projects that make this possible.
58+
59+
## Sponsoring services
60+
61+
![Netlify](https://www.netlify.com/v3/img/components/full-logo-light.svg)
62+
63+
[Netlify](https://www.netlify.com/) lets us distribute the [site](https://viewer.textea.io).

docs/theme.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default {
2+
project: {
3+
link: 'https://github.com./TexteaInc/json-viewer'
4+
}
5+
}

examples/basic/tsconfig.json renamed to docs/tsconfig.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"extends": "@textea/dev-kit/config/tsconfig.root.json",
33
"compilerOptions": {
4-
"baseUrl": ".",
54
"paths": {
6-
"@textea/json-viewer": ["../../src/index"]
5+
"@textea/json-viewer": [
6+
"../src/index"
7+
]
78
},
89
"jsx": "preserve",
9-
"jsxImportSource": "react",
10+
"incremental": true,
1011
"noEmit": true
1112
},
1213
"include": [

examples/basic/.eslintrc.js

-3
This file was deleted.

examples/basic/next-env.d.ts

-5
This file was deleted.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
},
110110
"packageManager": "[email protected]",
111111
"workspaces": [
112-
"examples/*"
112+
"examples/*",
113+
"docs"
113114
]
114115
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)