Skip to content

Commit

Permalink
refactor: next.js로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
hahnlee committed Apr 9, 2024
1 parent 3b14f51 commit 5f9deb7
Show file tree
Hide file tree
Showing 44 changed files with 1,186 additions and 8,497 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
"husky": "^9.0.11",
"jest": "^26.4.2",
"lint-staged": "^15.2.2",
"typescript": "^4.7.4"
"typescript": "^5.4.4"
}
}
9,367 changes: 955 additions & 8,412 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

36 changes: 35 additions & 1 deletion website/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
public/
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
2 changes: 0 additions & 2 deletions website/gatsby-browser.js

This file was deleted.

8 changes: 0 additions & 8 deletions website/gatsby-config.js

This file was deleted.

6 changes: 6 additions & 0 deletions website/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
transpilePackages: ['@hwp.js/parser', '@hwp.js/viewer'],
}

module.exports = nextConfig
28 changes: 10 additions & 18 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,21 @@
"license": "Apache-2.0",
"private": true,
"scripts": {
"build": "gatsby build --prefix-paths",
"develop": "gatsby develop",
"start": "npm run develop",
"serve": "gatsby serve",
"clean": "gatsby clean",
"deploy": "gh-pages -d public"
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"@hwp.js/parser": "workspace:*",
"@hwp.js/viewer": "workspace:*",
"gatsby": "^2.24.47",
"gatsby-plugin-react-helmet": "^3.3.10",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-dropzone": "^11.0.3",
"react-helmet": "^6.1.0",
"react-loader-spinner": "^3.1.14"
"next": "^14.1.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
"react-loader-spinner": "^6.1.6"
},
"devDependencies": {
"@types/react-helmet": "^6.1.0",
"@types/react-loader-spinner": "^3.1.0",
"gatsby-plugin-typescript": "^2.4.18",
"gatsby-source-filesystem": "^2.3.24",
"gh-pages": "^3.1.0"
"@types/react": "18.2.75",
"typescript": "^5.4.4"
}
}
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
8 changes: 4 additions & 4 deletions website/src/components/Page/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

import React, { ReactNode } from 'react'
import { Helmet } from 'react-helmet'
import Head from 'next/head'
import { ReactNode } from 'react'

interface PageProps {
title?: string
Expand All @@ -28,7 +28,7 @@ function Page({
}: PageProps) {
return (
<>
<Helmet>
<Head>
<title>{ title }</title>
<link rel="apple-touch-icon" sizes="57x57" href="favicon/apple-icon-57x57.png" />
<link rel="apple-touch-icon" sizes="60x60" href="favicon/apple-icon-60x60.png" />
Expand All @@ -50,7 +50,7 @@ function Page({
<meta property="og:title" content="hwp.js" />
<meta property="og:description" content="Open source hwp viewer and parser library powered by web technology" />
<meta property="og:image" content="images/logo.png" />
</Helmet>
</Head>
{ children }
</>
)
Expand Down
97 changes: 97 additions & 0 deletions website/src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import '../styles/global.css'

import type { AppProps } from 'next/app'
import Head from 'next/head'

export default function App({ Component, pageProps }: AppProps) {
return (
<>
<Head>
<title>hwp.js</title>
<link
rel="apple-touch-icon"
sizes="57x57"
href="favicon/apple-icon-57x57.png"
/>
<link
rel="apple-touch-icon"
sizes="60x60"
href="favicon/apple-icon-60x60.png"
/>
<link
rel="apple-touch-icon"
sizes="72x72"
href="favicon/apple-icon-72x72.png"
/>
<link
rel="apple-touch-icon"
sizes="76x76"
href="favicon/apple-icon-76x76.png"
/>
<link
rel="apple-touch-icon"
sizes="114x114"
href="favicon/apple-icon-114x114.png"
/>
<link
rel="apple-touch-icon"
sizes="120x120"
href="favicon/apple-icon-120x120.png"
/>
<link
rel="apple-touch-icon"
sizes="144x144"
href="favicon/apple-icon-144x144.png"
/>
<link
rel="apple-touch-icon"
sizes="152x152"
href="favicon/apple-icon-152x152.png"
/>
<link
rel="apple-touch-icon"
sizes="180x180"
href="favicon/apple-icon-180x180.png"
/>
<link
rel="icon"
type="image/png"
sizes="192x192"
href="favicon/android-icon-192x192.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="favicon/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="96x96"
href="favicon/favicon-96x96.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="favicon/favicon-16x16.png"
/>
<link rel="manifest" href="favicon/manifest.json" />
<meta name="msapplication-TileColor" content="#ffffff" />
<meta
name="msapplication-TileImage"
content="favicon/ms-icon-144x144.png"
/>
<meta name="theme-color" content="#ffffff" />
<meta property="og:title" content="hwp.js" />
<meta
property="og:description"
content="Open source hwp viewer and parser library powered by web technology"
/>
<meta property="og:image" content="images/logo.png" />
</Head>
<Component {...pageProps} />
</>
)
}
10 changes: 6 additions & 4 deletions website/src/pages/demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/
import { HWPViewer } from '@hwp.js/viewer'
import React, { useCallback, useState, useRef } from 'react'
import { useCallback, useState, useRef } from 'react'
import { useDropzone } from 'react-dropzone'

import Page from '../components/Page'
Expand Down Expand Up @@ -52,11 +52,13 @@ function Demo() {

const { getRootProps, getInputProps, isDragActive } = useDropzone({
onDrop,
accept: '.hwp'
accept: {
'application/hwp': ['.hwp'],
}
})

return (
<Page title="Demo - hwp.js">
<>
<div className="viewer" ref={ref}>
{
!isFileUploaded && (
Expand All @@ -79,7 +81,7 @@ function Demo() {
)
}
</div>
</Page>
</>
)
}

Expand Down
91 changes: 44 additions & 47 deletions website/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
* limitations under the License.
*/
import { HWPViewer } from '@hwp.js/viewer'
import React, { useState, useCallback, useEffect, useRef } from 'react'
import Loader from 'react-loader-spinner'

import Page from '../components/Page'
import { useState, useCallback, useEffect, useRef } from 'react'
import { Oval } from 'react-loader-spinner'

function IndexPage() {
const viewerRef = useRef<HTMLDivElement | null>(null)
Expand Down Expand Up @@ -47,49 +45,48 @@ function IndexPage() {
}, [])

return (
<Page title="hwp.js">
<main className="index">
<section className="main">
<img src="images/logo.svg" />
<p>Open source hwp viewer and parser library powered by web technology</p>
<a type="button" className="btn btn-default" href="https://github.com/hahnlee/hwp.js">GitHub</a>
<a type="button" className="btn btn-default" href="https://chrome.google.com/webstore/detail/hwpjs/hgalnnpknkjdccmcljadkckcdibiglei">
Chrome extension
</a>
<a type="button" className="btn btn-default" href="https://github.com/hahnlee/hwp.js/issues/7">공지사항</a>
<a type="button" className="btn btn-default" href="demo">Demo</a>
<pre className="code">
<code>
npm install hwp.js
<br />
yarn add hwp.js
</code>
</pre>
</section>
<div className="container" ref={viewerRef}>
{
isLoading && (
<div className="notice">
<Loader
type="Oval"
color="#00BFFF"
height={100}
width={100}
/>
</div>
)
}
{
hasError && (
<div className="notice">
<h1>에러가 발생했습니다 :(</h1>
<button className="btn btn-default" onClick={loadSampleHWP}>다시시도 하기</button>
</div>
)
}
</div>
</main>
</Page>
<main className="index">
<section className="main">
<img src="images/logo.svg" />
<p>Open source hwp viewer and parser library powered by web technology</p>
<a type="button" className="btn btn-default" href="https://github.com/hahnlee/hwp.js">GitHub</a>
<a type="button" className="btn btn-default" href="https://chrome.google.com/webstore/detail/hwpjs/hgalnnpknkjdccmcljadkckcdibiglei">
Chrome extension
</a>
<a type="button" className="btn btn-default" href="https://github.com/hahnlee/hwp.js/issues/7">공지사항</a>
<a type="button" className="btn btn-default" href="demo">Demo</a>
<pre className="code">
<code>
npm install hwp.js
<br />
yarn add hwp.js
<br />
pnpm add hwp.js
</code>
</pre>
</section>
<div className="container" ref={viewerRef}>
{
isLoading && (
<div className="notice">
<Oval
color="#00BFFF"
height={100}
width={100}
/>
</div>
)
}
{
hasError && (
<div className="notice">
<h1>에러가 발생했습니다 :(</h1>
<button className="btn btn-default" onClick={loadSampleHWP}>다시시도 하기</button>
</div>
)
}
</div>
</main>
)
}

Expand Down
28 changes: 28 additions & 0 deletions website/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
],
"exclude": [
"node_modules"
]
}

0 comments on commit 5f9deb7

Please sign in to comment.