diff --git a/src/components/Accent.tsx b/src/components/Accent.tsx index 40d1ac1..5d827d2 100644 --- a/src/components/Accent.tsx +++ b/src/components/Accent.tsx @@ -9,7 +9,6 @@ export default function Accent({ children, className }: AccentType) { { }, }); }; + +export type Tree = { + id: string; + link: string; + display: string; + order: number; +}; + +export const getSocialTree = async () => { + if (!NOTION_TREE_DATABASE_ID) { + throw new Error('NEXT_PUBLIC_NOTION_TREE_DATABASE_ID env is not defined'); + } + + const response = await notion.databases.query({ + database_id: NOTION_TREE_DATABASE_ID, + }); + + const results = response.results as unknown as TreeResult[]; + + const tree: Tree[] = results + .map((result) => ({ + id: result.id, + link: result.properties.link.title[0]?.plain_text, + display: result.properties.display.rich_text[0]?.plain_text ?? '', + order: result.properties.order.number, + })) + .sort((a, b) => a.order - b.order); + + return tree; +}; diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 507211e..7c468c0 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,23 +1,66 @@ +import clsx from 'clsx'; +import { InferGetStaticPropsType } from 'next'; import * as React from 'react'; +import { getSocialTree } from '@/lib/notion'; + import Accent from '@/components/Accent'; import Layout from '@/components/layout/Layout'; +import UnstyledLink from '@/components/links/UnstyledLink'; import Seo from '@/components/Seo'; -export default function IndexPage() { +export default function IndexPage({ + links, +}: InferGetStaticPropsType) { return (
-
+

Notiolink

+
+ {links.map(({ id, display, link }) => ( +
+
+ + + {display} + +
+ ))} +
); } + +export const getStaticProps = async () => { + return { + props: { links: await getSocialTree() }, + revalidate: 5, + }; +}; diff --git a/src/types/notion.ts b/src/types/notion.ts index 63936ab..d86849e 100644 --- a/src/types/notion.ts +++ b/src/types/notion.ts @@ -1,3 +1,4 @@ +//#region //*=========== Links =========== export interface LinkResult { id: string; properties: LinkProperties; @@ -8,20 +9,42 @@ interface LinkProperties { link: TextColumn; slug: TitleColumn; } +//#endregion //*======== Links =========== +//#region //*=========== Social Tree =========== +export interface TreeResult { + id: string; + properties: TreeProperties; +} + +interface TreeProperties { + link: TitleColumn; + display: TextColumn; + order: NumberColumn; +} +//#endregion //*======== Social Tree =========== + +//#region //*=========== Commons =========== interface TitleColumn { id: string; - type: string; + type: 'title'; title: [RichText]; } interface TextColumn { id: string; - type: string; + type: 'rich_text'; rich_text: [RichText | undefined]; } +interface NumberColumn { + id: string; + type: 'number'; + number: number; +} + interface RichText { type: string; plain_text: string; } +//#endregion //*======== Commons =========== diff --git a/tailwind.config.js b/tailwind.config.js index a695fd2..5923ac9 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -46,9 +46,21 @@ module.exports = { filter: 'none', }, }, + tilt: { + '0%, 50%, 100%': { + transform: 'rotate(0deg)', + }, + '25%': { + transform: 'rotate(0.7deg)', + }, + '75%': { + transform: 'rotate(-0.7deg)', + }, + }, }, animation: { flicker: 'flicker 3s linear infinite', + tilt: 'tilt 10s infinite linear', }, }, },