Skip to content
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

Use rotion instead of notionate and update packages #1

Merged
merged 4 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
52 changes: 28 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,22 @@ on:
push:
branches:
- main
schedule:
- cron: 0 3 * * *

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
node-version: [22.x]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache: npm
- name: Run builds and deploys with ${{ matrix.node-version }}
run: |
npm i && npm run lint
Expand All @@ -30,29 +32,30 @@ jobs:
if: github.ref != 'refs/heads/main'
env:
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
NOTIONATE_INCREMENTAL_CACHE: true
ROTION_INCREMENTAL_CACHE: true
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
node-version: 22
cache: npm
- name: Restore next cache
uses: actions/cache@v3
uses: actions/cache@v4.0.0
with:
path: |
.next/cache
key: nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Restore notionate cache
uses: actions/cache@v3
- name: Restore rotion cache
uses: actions/cache@v4.0.0
with:
path: |
.cache
public/images
key: notionate
restore-keys: notionate
public/files
key: rotion
restore-keys: rotion
- name: Run next build
run: |
npm i && npm run build
Expand All @@ -72,29 +75,30 @@ jobs:
if: github.ref == 'refs/heads/main'
env:
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
NOTIONATE_INCREMENTAL_CACHE: true
ROTION_INCREMENTAL_CACHE: true
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
node-version: 22
cache: npm
- name: Restore next cache
uses: actions/cache@v3
uses: actions/cache@v4.0.0
with:
path: |
.next/cache
key: nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Restore notionate cache
uses: actions/cache@v3
- name: Restore rotion cache
uses: actions/cache@v4.0.0
with:
path: |
.cache
public/images
key: notionate
restore-keys: notionate
public/files
key: rotion
restore-keys: rotion
- name: Run next build
run: |
npm i && npm run build
Expand Down
20 changes: 16 additions & 4 deletions lib/contents.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
import { DBPropsMembers } from '@/lib/members'
import {
FetchBlocks,
FetchDatabase,
ListBlockChildrenResponseEx,
QueryDatabaseParameters,
PageObjectResponseEx,
} from 'notionate'
RichTextItemResponse,
DBPageBase,
} from 'rotion'

export type DBPropsMembers = DBPageBase & {
properties: {
Name: {
type: 'title',
title: RichTextItemResponse[],
}
}
}

export const GetContent = async (title: string): Promise<ListBlockChildrenResponseEx> => {
const { results } = await FetchDatabase({
database_id: process.env.NOTION_CONTENTS_DB_ID,
} as QueryDatabaseParameters)

const page = results.find(v => {
const p = v as DBPropsMembers
const p = v as unknown as DBPropsMembers
return p.properties.Name.title.map(v => v.plain_text).join(',') === title
}) as PageObjectResponseEx
return await FetchBlocks(page.id, page.last_edited_time)

return await FetchBlocks({ block_id: page.id, last_edited_time: page.last_edited_time })
}

3 changes: 1 addition & 2 deletions lib/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import {
FetchDatabase,
QueryDatabaseResponseEx,
QueryDatabaseParameters,
} from 'notionate'
} from 'rotion'

export const GetEvents = async (): Promise<QueryDatabaseResponseEx> => {
return await FetchDatabase({
database_id: process.env.NOTION_EVENTS_DB_ID,
sorts: [ { property: 'Date', direction: 'descending' }, ],
} as QueryDatabaseParameters)
}

3 changes: 1 addition & 2 deletions lib/facts.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {
FetchDatabase,
QueryDatabaseParameters,
PersonUserObjectResponseEx,
SelectPropertyResponse,
RichTextItemResponse,
DBPageBase,
} from 'notionate'
} from 'rotion'

export type Fact = {
id: string,
Expand Down
2 changes: 1 addition & 1 deletion lib/members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
DateResponse,
RichTextItemResponse,
DBPageBase,
} from 'notionate'
} from 'rotion'

export type Member = {
id: string
Expand Down
Loading