Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksongoode committed Nov 7, 2024
2 parents a9bc456 + 163fda4 commit 20215dc
Show file tree
Hide file tree
Showing 46 changed files with 297 additions and 252 deletions.
34 changes: 12 additions & 22 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "react", "react-hooks"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"prettier"
],
"settings": {
"react": {
"version": "detect"
}
},
"env": {
"browser": true,
"node": true
},
"extends": ["@fisch0920/eslint-config"],
"rules": {
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-non-null-assertion": 0,
"@typescript-eslint/no-unused-vars": 2,
"react/prop-types": 0
"react/prop-types": "off",
"unicorn/no-array-reduce": "off",
"unicorn/filename-case": "off",
"no-process-env": "off",
"array-callback-return": "off",
"jsx-a11y/click-events-have-key-events": "off",
"jsx-a11y/no-static-element-interactions": "off",
"jsx-a11y/media-has-caption": "off",
"jsx-a11y/interactive-supports-focus": "off",
"jsx-a11y/anchor-is-valid": "off",
"@typescript-eslint/naming-convention": "off"
}
}
49 changes: 32 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,44 @@
name: Build
name: CI

on: [push, pull_request]

jobs:
Build:
test:
name: Test Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
node-version:
- 18
- 22

steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
- name: Install pnpm
uses: pnpm/action-setup@v3
id: pnpm-install
with:
node-version: '20'
version: 9.12.2
run_install: false

- name: Setup pnpm
uses: pnpm/action-setup@v2
- name: Install Node.js
uses: actions/setup-node@v4
with:
version: 8
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Build
# TODO Enable those lines below if you use a Redis cache, you'll also need to configure GitHub Repository Secrets
# env:
# REDIS_HOST: ${{ secrets.REDIS_HOST }}
# REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD }}
run: pnpm build
run: pnpm install --frozen-lockfile --strict-peer-dependencies

- name: Run test
run: pnpm test

# TODO Enable those lines below if you use a Redis cache, you'll also need to configure GitHub Repository Secrets
# env:
# REDIS_HOST: ${{ secrets.REDIS_HOST }}
# REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD }}
# - name: Build
# run: pnpm build
11 changes: 1 addition & 10 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,5 @@
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "always",
"trailingComma": "none",
"importOrder": [
"^(react/(.*)$)|^(react$)|^(next/(.*)$)|^(next$)",
"<THIRD_PARTY_MODULES>",
"^(@/lib/(.*)$)|^(@/components/(.*)$)|^(@/styles/(.*)$)",
"^[./]"
],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"importOrderGroupNamespaceSpecifiers": true
"trailingComma": "none"
}
1 change: 0 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/next",
"runtimeArgs": ["dev"],
"cwd": "${workspaceFolder}",
"port": 9229,
"smartStep": true,
"console": "integratedTerminal",
"skipFiles": ["<node_internals>/**"],
Expand Down
4 changes: 1 addition & 3 deletions components/ErrorPage.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import * as React from 'react'

import { PageHead } from './PageHead'
import styles from './styles.module.css'

export const ErrorPage: React.FC<{ statusCode: number }> = ({ statusCode }) => {
export function ErrorPage({ statusCode }: { statusCode: number }) {
const title = 'Error'

return (
Expand Down
2 changes: 1 addition & 1 deletion components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import styles from './styles.module.css'

// TODO: merge the data and icons from PageSocial with the social links in Footer

export const FooterImpl: React.FC = () => {
export function FooterImpl() {
const [hasMounted, setHasMounted] = React.useState(false)
const { isDarkMode, toggleDarkMode } = useDarkMode()
const currentYear = new Date().getFullYear()
Expand Down
14 changes: 7 additions & 7 deletions components/Loading.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as React from 'react'

import { LoadingIcon } from './LoadingIcon'
import styles from './styles.module.css'

export const Loading: React.FC = () => (
<div className={styles.container}>
<LoadingIcon />
</div>
)
export function Loading() {
return (
<div className={styles.container}>
<LoadingIcon />
</div>
)
}
4 changes: 1 addition & 3 deletions components/LoadingIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import * as React from 'react'

import cs from 'classnames'

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

export const LoadingIcon = (props) => {
export function LoadingIcon(props: any) {
const { className, ...rest } = props
return (
<svg
Expand Down
23 changes: 11 additions & 12 deletions components/NotionPage.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import * as React from 'react'
import cs from 'classnames'
import dynamic from 'next/dynamic'
import Image from 'next/image'
import Image from 'next/legacy/image'
import Link from 'next/link'
import { useRouter } from 'next/router'

import cs from 'classnames'
import { PageBlock } from 'notion-types'
import { type PageBlock } from 'notion-types'
import { formatDate, getBlockTitle, getPageProperty } from 'notion-utils'
import * as React from 'react'
import BodyClassName from 'react-body-classname'
import { NotionRenderer } from 'react-notion-x'
import { type NotionComponents, NotionRenderer } from 'react-notion-x'
import TweetEmbed from 'react-tweet-embed'
import { useSearchParam } from 'react-use'

import type * as types from '@/lib/types'
import * as config from '@/lib/config'
import * as types from '@/lib/types'
import { mapImageUrl } from '@/lib/map-image-url'
import { getCanonicalPageUrl, mapPageUrl } from '@/lib/map-page-url'
import { searchNotion } from '@/lib/search-notion'
Expand Down Expand Up @@ -96,7 +95,7 @@ const Modal = dynamic(
}
)

const Tweet = ({ id }: { id: string }) => {
function Tweet({ id }: { id: string }) {
return <TweetEmbed tweetId={id} />
}

Expand Down Expand Up @@ -141,18 +140,18 @@ const propertyTextValue = (
return defaultFn()
}

export const NotionPage: React.FC<types.PageProps> = ({
export function NotionPage({
site,
recordMap,
error,
pageId
}) => {
}: types.PageProps) {
const router = useRouter()
const lite = useSearchParam('lite')

const components = React.useMemo(
const components = React.useMemo<Partial<NotionComponents>>(
() => ({
nextImage: Image,
nextLegacyImage: Image,
nextLink: Link,
Code,
Collection,
Expand Down
9 changes: 6 additions & 3 deletions components/NotionPageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as types from 'notion-types'
import { IoMoonSharp } from 'react-icons/io5'
import { IoSunnyOutline } from 'react-icons/io5'
import cs from 'classnames'
import * as React from 'react'
import { Breadcrumbs, Header, Search, useNotionContext } from 'react-notion-x'

import { isSearchEnabled, navigationLinks, navigationStyle } from '@/lib/config'
Expand All @@ -12,7 +13,7 @@ import { getBlockTitle } from 'notion-utils'

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

const ToggleThemeButton = () => {
function ToggleThemeButton() {
const [hasMounted, setHasMounted] = React.useState(false)
const { isDarkMode, toggleDarkMode } = useDarkMode()

Expand All @@ -34,9 +35,11 @@ const ToggleThemeButton = () => {
)
}

export const NotionPageHeader: React.FC<{
export function NotionPageHeader({
block
}: {
block: types.CollectionViewPageBlock | types.PageBlock
}> = ({ block }) => {
}) {
const { components, mapPageUrl, recordMap } = useNotionContext()
const [showTitle, setShowTitle] = React.useState(false)
const title = getBlockTitle(block, recordMap)
Expand Down
6 changes: 2 additions & 4 deletions components/Page404.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import * as React from 'react'

import * as types from '@/lib/types'
import type * as types from '@/lib/types'

import { PageHead } from './PageHead'
import styles from './styles.module.css'
import * as config from '@/lib/config'

export const Page404: React.FC<types.PageProps> = ({ site, pageId, error }) => {
export function Page404({ site, pageId, error }: types.PageProps) {
const title = site?.name || 'Page Not Found'

return (
Expand Down
2 changes: 1 addition & 1 deletion components/PageActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import styles from './styles.module.css'
/**
* @see https://developer.twitter.com/en/docs/twitter-for-websites/web-intents/overview
*/
export const PageActions: React.FC<{ tweet: string }> = ({ tweet }) => {
export function PageActions({ tweet }: { tweet: string }) {
return (
<div className={styles.pageActions}>
<a
Expand Down
12 changes: 7 additions & 5 deletions components/PageAside.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import * as React from 'react'

import { Block, ExtendedRecordMap } from 'notion-types'
import { type Block, type ExtendedRecordMap } from 'notion-types'

import { getPageTweet } from '@/lib/get-page-tweet'

import { PageActions } from './PageActions'
// import { PageSocial } from './PageSocial'

export const PageAside: React.FC<{
export function PageAside({
block,
recordMap,
isBlogPost
}: {
block: Block
recordMap: ExtendedRecordMap
isBlogPost: boolean
}> = ({ block, recordMap, isBlogPost }) => {
}) {
if (!block) {
return null
}
Expand Down
41 changes: 26 additions & 15 deletions components/PageHead.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import * as React from 'react'
import Head from 'next/head'

import type * as types from '@/lib/types'
import * as config from '@/lib/config'
import * as types from '@/lib/types'
import { getSocialImageUrl } from '@/lib/get-social-image-url'

export const PageHead: React.FC<
types.PageProps & {
title?: string
description?: string
image?: string
url?: string
}
> = ({ site, title, description, pageId, image, url }) => {
export function PageHead({
site,
title,
description,
pageId,
image,
url
}: types.PageProps & {
title?: string
description?: string
image?: string
url?: string
}) {
const rssFeedUrl = `${config.host}/feed`

title = title ?? site?.name
Expand All @@ -30,13 +34,20 @@ export const PageHead: React.FC<
/>

<meta name='apple-mobile-web-app-capable' content='yes' />
<meta name='apple-mobile-web-app-status-bar-style' content='black' />

<meta
name='apple-mobile-web-app-status-bar-style'
content='black'
name='theme-color'
media='(prefers-color-scheme: light)'
content='#fefffe'
key='theme-color-light'
/>
<meta
name='theme-color'
media='(prefers-color-scheme: dark)'
content='#2d3439'
key='theme-color-dark'
/>

<meta name="theme-color" media="(prefers-color-scheme: light)" content="#fefffe" key="theme-color-light"/>
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#2d3439" key="theme-color-dark"/>

<meta name='robots' content='index,follow' />
<meta property='og:type' content='website' />
Expand Down
4 changes: 2 additions & 2 deletions components/PageSocial.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@
}

.youtube .actionBgPane {
background: #FF0000;
background: #ff0000;
}
.youtube:hover {
border-color: #FF0000;
border-color: #ff0000;
}

.medium .actionBgPane {
Expand Down
Loading

0 comments on commit 20215dc

Please sign in to comment.