forked from transitive-bullshit/nextjs-notion-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: copying initial skeleton from Notion2Site
- Loading branch information
1 parent
582a8f5
commit 253400f
Showing
28 changed files
with
3,816 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"parser": "babel-eslint", | ||
"extends": [ | ||
"standard", | ||
"standard-react", | ||
"plugin:prettier/recommended", | ||
"prettier/standard", | ||
"prettier/react" | ||
], | ||
"env": { | ||
"node": true | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 2020, | ||
"ecmaFeatures": { | ||
"legacyDecorators": true, | ||
"jsx": true | ||
} | ||
}, | ||
"settings": { | ||
"react": { | ||
"version": "16" | ||
} | ||
}, | ||
"rules": { | ||
"space-before-function-paren": 0, | ||
"react/prop-types": 0, | ||
"react/jsx-handler-names": 0, | ||
"react/jsx-fragments": 0, | ||
"react/no-unused-prop-types": 0, | ||
"import/export": 0, | ||
"standard/no-callback-literal": 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.snapshots/ | ||
build/ | ||
dist/ | ||
node_modules/ | ||
.next/ | ||
.vercel/ | ||
|
||
.demo/ | ||
.renderer/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"singleQuote": true, | ||
"jsxSingleQuote": true, | ||
"semi": false, | ||
"useTabs": false, | ||
"tabWidth": 2, | ||
"bracketSpacing": true, | ||
"jsxBracketSameLine": false, | ||
"arrowParens": "always", | ||
"trailingComma": "none" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "next dev", | ||
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/next", | ||
"runtimeArgs": ["dev"], | ||
"cwd": "${workspaceFolder}", | ||
"port": 9229, | ||
"smartStep": true, | ||
"console": "integratedTerminal", | ||
"skipFiles": ["<node_internals>/**"], | ||
"env": { | ||
"NODE_OPTIONS": "--inspect" | ||
} | ||
}, | ||
{ | ||
"type": "node", | ||
"request": "attach", | ||
"name": "Next.js App", | ||
"skipFiles": ["<node_internals>/**"], | ||
"port": 9229 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"files.exclude": { | ||
"**/logs": true, | ||
"**/*.log": true, | ||
"**/npm-debug.log*": true, | ||
"**/yarn-debug.log*": true, | ||
"**/yarn-error.log*": true, | ||
"**/pids": true, | ||
"**/*.pid": true, | ||
"**/*.seed": true, | ||
"**/*.pid.lock": true, | ||
"**/.dummy": true, | ||
"**/lib-cov": true, | ||
"**/coverage": true, | ||
"**/.nyc_output": true, | ||
"**/.grunt": true, | ||
"**/.snapshots/": true, | ||
"**/bower_components": true, | ||
"**/.lock-wscript": true, | ||
"build/Release": true, | ||
"**/node_modules/": true, | ||
"**/jspm_packages/": true, | ||
"**/typings/": true, | ||
"**/.npm": true, | ||
"**/.eslintcache": true, | ||
"**/.node_repl_history": true, | ||
"**/*.tgz": true, | ||
"**/.yarn-integrity": true, | ||
"**/.next/": true, | ||
"**/dist/": true, | ||
"**/build/": true, | ||
"**/.now/": true, | ||
"**/.vercel/": true, | ||
"**/.google.json": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// const isDev = process.env.NODE_ENV === 'development' || !process.env.NODE_ENV | ||
|
||
const withBundleAnalyzer = require('@next/bundle-analyzer')({ | ||
enabled: process.env.ANALYZE === 'true' | ||
}) | ||
|
||
module.exports = withBundleAnalyzer({}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,61 @@ | |
"name": "transitive-bullshit", | ||
"version": "0.1.0", | ||
"private": true, | ||
"description": "Personal site of Travis Fischer using Notion as a CMS.", | ||
"author": "Travis Fischer <[email protected]>", | ||
"repository": "transitive-bullshit/transitivebullsh.it", | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=10" | ||
}, | ||
"scripts": { | ||
"dev": "next dev", | ||
"build": "next build", | ||
"start": "next start" | ||
"start": "next start", | ||
"deploy": "vercel --prod", | ||
"deps": "run-s deps:*", | ||
"deps:update": "[ -z $GITHUB_ACTIONS ] && yarn add notion-client notion-types notion-utils || echo 'Skipping deps:update on CI'", | ||
"deps:link": "[ -z $GITHUB_ACTIONS ] && yarn link notion-client notion-types notion-utils || echo 'Skipping deps:link on CI'", | ||
"analyze": "cross-env ANALYZE=true next build", | ||
"analyze:server": "cross-env BUNDLE_ANALYZE=server next build", | ||
"analyze:browser": "cross-env BUNDLE_ANALYZE=browser next build", | ||
"test": "run-s test:*", | ||
"test:lint": "eslint .", | ||
"test:prettier": "prettier '**/*.{js,jsx,ts,tsx}' --check" | ||
}, | ||
"dependencies": { | ||
"@google-cloud/firestore": "^4.8.1", | ||
"classnames": "^2.2.6", | ||
"lqip-modern": "^1.1.3", | ||
"next": "10.0.5", | ||
"notion-client": "^2.4.1", | ||
"notion-types": "^2.2.1", | ||
"notion-utils": "^2.4.1", | ||
"p-map": "^4.0.0", | ||
"p-memoize": "^4.0.0", | ||
"react": "17.0.1", | ||
"react-dom": "17.0.1" | ||
"react-dom": "17.0.1", | ||
"react-use": "^15.3.3" | ||
}, | ||
"devDependencies": { | ||
"@next/bundle-analyzer": "^10.0.5", | ||
"@types/classnames": "^2.2.10", | ||
"@types/node": "^14.6.0", | ||
"@types/react": "^17.0.0", | ||
"babel-eslint": "^10.0.3", | ||
"cross-env": "^7.0.2", | ||
"eslint": "^7.2.0", | ||
"eslint-config-prettier": "^7.1.0", | ||
"eslint-config-standard": "^16.0.2", | ||
"eslint-config-standard-react": "^11.0.1", | ||
"eslint-plugin-import": "^2.21.2", | ||
"eslint-plugin-node": "^11.0.0", | ||
"eslint-plugin-prettier": "^3.1.1", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"eslint-plugin-react": "^7.18.0", | ||
"next-svgr": "^0.0.2", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.0.5", | ||
"typescript": "^4.0.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { Page404 } from 'components' | ||
|
||
export default Page404 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'styles/global.css' | ||
import 'react-notion/styles.css' | ||
import 'prismjs/themes/prism-tomorrow.css' | ||
import 'rc-dropdown/assets/index.css' | ||
import 'katex/dist/katex.min.css' | ||
|
||
import React from 'react' | ||
import { useEffect } from 'react' | ||
import { useRouter } from 'next/router' | ||
import { bootstrap } from 'lib/bootstrap-client' | ||
import { fathomId, fathomConfig } from 'lib/config' | ||
import * as Fathom from 'fathom-client' | ||
|
||
if (typeof window !== 'undefined') { | ||
bootstrap() | ||
} | ||
|
||
export default function App({ Component, pageProps }) { | ||
const router = useRouter() | ||
|
||
useEffect(() => { | ||
if (fathomId) { | ||
Fathom.load(fathomId, fathomConfig) | ||
|
||
function onRouteChangeComplete() { | ||
Fathom.trackPageview() | ||
} | ||
|
||
router.events.on('routeChangeComplete', onRouteChangeComplete) | ||
|
||
return () => { | ||
router.events.off('routeChangeComplete', onRouteChangeComplete) | ||
} | ||
} | ||
}, []) | ||
|
||
return <Component {...pageProps} /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import * as React from 'react' | ||
import Document, { Html, Head, Main, NextScript } from 'next/document' | ||
|
||
export default class MyDocument extends Document { | ||
render() { | ||
return ( | ||
<Html lang='en'> | ||
<Head /> | ||
|
||
<body> | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</Html> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { ErrorPage } from 'components' | ||
|
||
export default ErrorPage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { NextApiRequest, NextApiResponse } from 'next' | ||
|
||
import got from 'got' | ||
import lqip from 'lqip-modern' | ||
|
||
import * as types from '../../lib/types' | ||
import * as db from '../../lib/db' | ||
|
||
export default async (req: NextApiRequest, res: NextApiResponse) => { | ||
if (req.method !== 'POST') { | ||
return res.status(405).send({ error: 'method not allowed' }) | ||
} | ||
|
||
const { url, id } = req.body | ||
|
||
const result = await createPreviewImage(url, id) | ||
|
||
res.setHeader( | ||
'Cache-Control', | ||
result.error | ||
? 'public, s-maxage=60, max-age=60, stale-while-revalidate=60' | ||
: 'public, immutable, s-maxage=31536000, max-age=31536000, stale-while-revalidate=60' | ||
) | ||
res.status(200).json(result) | ||
} | ||
|
||
export async function createPreviewImage( | ||
url: string, | ||
id: string | ||
): Promise<types.PreviewImage> { | ||
const doc = db.images.doc(id) | ||
|
||
try { | ||
const model = await doc.get() | ||
if (model.exists) { | ||
return model.data() as types.PreviewImage | ||
} | ||
|
||
const { body } = await got(url, { responseType: 'buffer' }) | ||
const result = await lqip(body) | ||
console.log('lqip', result.metadata) | ||
|
||
const image = { | ||
url, | ||
originalWidth: result.metadata.originalWidth, | ||
originalHeight: result.metadata.originalHeight, | ||
width: result.metadata.width, | ||
height: result.metadata.height, | ||
type: result.metadata.type, | ||
dataURIBase64: result.metadata.dataURIBase64 | ||
} | ||
|
||
await doc.create(image) | ||
return image | ||
} catch (err) { | ||
console.error('lqip error', err) | ||
|
||
try { | ||
const error: any = { | ||
url, | ||
error: err.message || 'unknown error' | ||
} | ||
|
||
if (err?.response?.statusCode) { | ||
error.statusCode = err?.response?.statusCode | ||
} | ||
|
||
await doc.create(error) | ||
return error | ||
} catch (err) { | ||
// ignore errors | ||
console.error(err) | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.