Skip to content

Commit

Permalink
feat: bug fixes and update core deps
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit committed Mar 25, 2022
1 parent ea64a04 commit c7a80fb
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 137 deletions.
7 changes: 4 additions & 3 deletions components/NotionPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as React from 'react'
import Head from 'next/head'
import Link from 'next/link'
import Image from 'next/image'
import dynamic from 'next/dynamic'
import cs from 'classnames'
import { useRouter } from 'next/router'
Expand All @@ -12,7 +14,6 @@ import { Tweet, TwitterContextProvider } from 'react-static-tweets'

// core notion renderer
import { NotionRenderer } from 'react-notion-x'
import { Image, PageLink } from 'react-notion-x/build/esm/third-party/next'

// utils
import { getBlockTitle } from 'notion-utils'
Expand Down Expand Up @@ -208,8 +209,8 @@ export const NotionPage: React.FC<types.PageProps> = ({
pageId === site.rootNotionPageId && 'index-page'
)}
components={{
Image,
PageLink,
nextImage: Image,
nextLink: Link,
Code,
Collection,
Equation,
Expand Down
4 changes: 3 additions & 1 deletion lib/get-all-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { getCanonicalPageId } from './get-canonical-page-id'

const uuid = !!includeNotionIdInUrls

export const getAllPages = pMemoize(getAllPagesImpl, { maxAge: 60000 * 5 })
export const getAllPages = pMemoize(getAllPagesImpl, {
cacheKey: (...args) => JSON.stringify(args)
})

export async function getAllPagesImpl(
rootNotionPageId: string,
Expand Down
6 changes: 5 additions & 1 deletion lib/search-notion.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
// import ky from 'ky'
import fetch from 'isomorphic-unfetch'
import pMemoize from 'p-memoize'
import ExpiryMap from 'expiry-map'

import { api } from './config'
import * as types from './types'

export const searchNotion = pMemoize(searchNotionImpl, { maxAge: 10000 })
export const searchNotion = pMemoize(searchNotionImpl, {
cacheKey: (args) => args[0]?.query,
cache: new ExpiryMap(10000)
})

async function searchNotionImpl(
params: types.SearchParams
Expand Down
15 changes: 4 additions & 11 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
const withPlugins = require('next-compose-plugins')
// const withTM = require('next-transpile-modules')([
// 'react-notion-x',
// 'notion-client',
// 'notion-utils',
// 'notion-types'
// ])
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true'
})
import withBundleAnalyzer from '@next/bundle-analyzer'

module.exports = withPlugins([withBundleAnalyzer], {
export default withBundleAnalyzer({
enabled: process.env.ANALYZE === 'true'
})({
staticPageGenerationTimeout: 300,
images: {
domains: [
Expand Down
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"name": "nextjs-notion-starter-kit",
"version": "0.1.0",
"private": true,
"type": "module",
"description": "The perfect starter kit for building beautiful websites with Next.js and Notion.",
"author": "Travis Fischer <[email protected]>",
"repository": "transitive-bullshit/nextjs-notion-starter-kit",
"license": "MIT",
"engines": {
"node": ">=10"
"node": ">=12"
},
"scripts": {
"dev": "next dev",
Expand All @@ -28,23 +29,24 @@
"@keyv/redis": "^2.2.3",
"classnames": "^2.3.1",
"date-fns": "^2.25.0",
"expiry-map": "^2.0.0",
"fathom-client": "^3.0.0",
"got": "^11.8.2",
"isomorphic-unfetch": "^3.1.0",
"keyv": "^4.1.1",
"lqip-modern": "^1.2.0",
"next": "^12.1.0",
"node-fetch": "^2.6.1",
"notion-client": "^5.0.0",
"notion-types": "^5.0.0",
"notion-utils": "^5.0.0",
"p-map": "^4.0.0",
"p-memoize": "^4.0.0",
"notion-client": "^6.0.0",
"notion-types": "^6.0.0",
"notion-utils": "^6.0.0",
"p-map": "^5.3.0",
"p-memoize": "^6.0.1",
"react": "^17.0.2",
"react-body-classname": "^1.3.1",
"react-dom": "^17.0.2",
"react-icons": "^4.3.1",
"react-notion-x": "^5.0.0",
"react-notion-x": "^6.0.0",
"react-static-tweets": "^0.7.1",
"react-use": "^17.3.2",
"static-tweets": "^0.7.1",
Expand All @@ -64,7 +66,6 @@
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.3.0",
"next-compose-plugins": "^2.2.1",
"next-transpile-modules": "^9.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.4.1",
"typescript": "^4.4.4"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion api/robots.txt.ts → pages/api/robots.txt.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'

import { host } from '../lib/config'
import { host } from '../../lib/config'

export default async (
req: NextApiRequest,
Expand Down
4 changes: 2 additions & 2 deletions api/search-notion.ts → pages/api/search-notion.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NextApiRequest, NextApiResponse } from 'next'

import * as types from '../lib/types'
import { search } from '../lib/notion'
import * as types from '../../lib/types'
import { search } from '../../lib/notion'

export default async (req: NextApiRequest, res: NextApiResponse) => {
if (req.method !== 'POST') {
Expand Down
15 changes: 8 additions & 7 deletions api/sitemap.xml.ts → pages/api/sitemap.xml.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NextApiRequest, NextApiResponse } from 'next'

import { SiteMap } from '../lib/types'
import { host } from '../lib/config'
import { getSiteMaps } from '../lib/get-site-maps'
import { SiteMap } from '../../lib/types'
import { host } from '../../lib/config'
import { getSiteMaps } from '../../lib/get-site-maps'

export default async (
req: NextApiRequest,
Expand All @@ -24,9 +24,9 @@ export default async (
res.end()
}

const createSitemap = (
siteMap: SiteMap
) => `<?xml version="1.0" encoding="UTF-8"?>
const createSitemap = (siteMap: SiteMap) =>
`
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>${host}</loc>
Expand All @@ -46,4 +46,5 @@ const createSitemap = (
)
.join('')}
</urlset>
`
</xml>
`
2 changes: 1 addition & 1 deletion site.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
// where it all starts -- the site's root Notion page (required)
rootNotionPageId: '78fc5a4b88d74b0e824e29407e9f1ec1',

Expand Down
Loading

0 comments on commit c7a80fb

Please sign in to comment.