Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Footer adjustments #596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
RSimmz98 wants to merge 5 commits into transitive-bullshit:main
base: main
Choose a base branch
Loading
from RSimmz98:richson
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP
  • Loading branch information
commit 20319d21c180a8118d8d12623fc94e419b208b4c
10 changes: 5 additions & 5 deletions components/NotionPage.tsx
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { ReactUtterances } from './ReactUtterances'

import styles from './styles.module.css'

// NOTE: if your site doesn't use these, then we recommend switching them to load lazily
// const Code = dynamic(() =>
// import('react-notion-x').then((notion) => notion.Code)
// )
Expand All @@ -59,10 +60,6 @@ const Equation = dynamic(() =>
import('react-notion-x').then((notion) => notion.Equation)
)

// we're now using a much lighter-weight tweet renderer react-static-tweets
// instead of the official iframe-based embed widget from twitter
// const Tweet = dynamic(() => import('react-tweet-embed'))

const Modal = dynamic(
() => import('react-notion-x').then((notion) => notion.Modal),
{ ssr: false }
Expand Down Expand Up @@ -108,7 +105,7 @@ export const NotionPage: React.FC<types.PageProps> = ({
})

if (!config.isServer) {
// add important objects to the window global for easy debugging
// add important variables to the global window object for easy debugging
const g = window as any
g.pageId = pageId
g.recordMap = recordMap
Expand All @@ -122,6 +119,9 @@ export const NotionPage: React.FC<types.PageProps> = ({

// const isRootPage =
// parsePageId(block.id) === parsePageId(site.rootNotionPageId)

// this is all very customizable logic depending on the contents and
// structure of your site
const isBlogPost =
block.type === 'page' && block.parent_table === 'collection'
const showTableOfContents = !!isBlogPost
Expand Down
5 changes: 5 additions & 0 deletions lib/canonical-page-map-cache.ts
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { CanonicalPageMap } from './types'

export const getCanonicalPageMapCache = async (): Promise<CanonicalPageMap> => {
// TODO
}
99 changes: 99 additions & 0 deletions lib/cloudflare-kv.ts
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import fetch from 'node-fetch'

export class CloudflareKV {
accountId: string
apiKey: string
namespaceId: string
_headers: any

constructor({
accountId,
apiKey,
namespaceId
}: {
accountId: string
apiKey: string
namespaceId: string
}) {
this.accountId = accountId
this.apiKey = apiKey
this.namespaceId = namespaceId

this._headers = {
Authorization: `Bearer ${this.apiKey}`
}
}

async get(key: string) {
const url = this._getUrl(key)
const headers = this._headers

const res = await fetch(url, {
headers
})

if (res.ok) {
return res.text()
} else if (res.status === 404) {
return undefined
} else {
const body = await res.text()

throw new Error(`Error ${res.status} ${body}`)
}
}

async put(
key: string,
value,
{
expiration,
expirationTtl
}: {
expiration?: number
expirationTtl?: number
} = {}
) {
const url = new URL(this._getUrl(key))
const headers = this._headers
const query: any = {}

if (expiration) {
query.expiration = expiration
}

if (expirationTtl) {
query.expiration_ttl = Math.max(60, expirationTtl)
}

url.search = new URLSearchParams(query).toString()
const res = await fetch(url.toString(), {
method: 'PUT',
body: value,
headers
})

console.log('CLOUDFLARE PUT', { key, value, ok: res.ok })
if (!res.ok) {
console.log(await res.text())
}
return res.ok
}

async delete(key: string): Promise<boolean> {
const url = this._getUrl(key)
const headers = this._headers

const res = await fetch(url, {
method: 'DELETE',
headers
})

return res.ok
}

_getUrl(key: string) {
const { accountId, namespaceId } = this
return `https://api.cloudflare.com/client/v4/accounts/${accountId}/storage/kv/namespaces/${namespaceId}/values/${key}`
}
}
13 changes: 10 additions & 3 deletions lib/get-all-pages.ts
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pMemoize from 'p-memoize'
import { getAllPagesInSpace } from 'notion-utils'
import stringify from 'fast-json-stable-stringify'

import * as types from './types'
import { includeNotionIdInUrls } from './config'
Expand All @@ -8,19 +9,24 @@ import { getCanonicalPageId } from './get-canonical-page-id'

const uuid = !!includeNotionIdInUrls

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

export async function getAllPagesImpl(
rootNotionPageId: string,
rootNotionSpaceId: string,
{
concurrency = 4,
pageConcurrency = 3,
full = false
full = false,
targetPageId = null
}: {
concurrency?: number
pageConcurrency?: number
full?: boolean
targetPageId?: string
} = {}
): Promise<types.PartialSiteMap> {
const pageMap = await getAllPagesInSpace(
Expand All @@ -32,7 +38,8 @@ export async function getAllPagesImpl(
concurrency: pageConcurrency
}),
{
concurrency
concurrency,
targetPageId
}
)

Expand Down
1 change: 1 addition & 0 deletions lib/types.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export interface PartialSiteMap {
}

export interface CanonicalPageMap {
// inverse page mapping from canonial path to page id
[canonicalPageId: string]: string
}

Expand Down
1 change: 1 addition & 0 deletions package.json
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"chrome-aws-lambda": "^5.5.0",
"classnames": "^2.2.6",
"dangerously-set-html-content": "^1.0.8",
"fast-json-stable-stringify": "^2.1.0",
"fathom-client": "^3.0.0",
"got": "^11.8.1",
"isomorphic-unfetch": "^3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2226,7 +2226,7 @@ fast-glob@^3.1.1:
micromatch "^4.0.2"
picomatch "^2.2.1"

fast-json-stable-stringify@^2.0.0:
fast-json-stable-stringify@^2.0.0, fast-json-stable-stringify@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"
integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==
Expand Down

AltStyle によって変換されたページ (->オリジナル) /