Skip to content

Commit

Permalink
Merge pull request #45 from otoyo/features-0.3
Browse files Browse the repository at this point in the history
Features 0.3
  • Loading branch information
otoyo authored Feb 25, 2023
2 parents ace1db3 + 04fbde9 commit 37e955d
Show file tree
Hide file tree
Showing 79 changed files with 3,135 additions and 1,325 deletions.
8 changes: 5 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"plugins": ["@typescript-eslint"],
"extends": ["plugin:@typescript-eslint/recommended", "plugin:astro/recommended"],
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:astro/recommended"
],
"rules": {
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-explicit-any": "error"
Expand All @@ -13,8 +16,7 @@
"parser": "@typescript-eslint/parser",
"extraFileExtensions": [".astro"]
},
"rules": {
}
"rules": {}
}
]
}
27 changes: 18 additions & 9 deletions .github/ISSUE_TEMPLATE/bug-report.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,52 @@ about: 発生している不具合を報告します
title: ''
labels: ''
assignees: ''

---

## 不具合の概要

発生している不具合について明確かつ簡潔に記述します。

## 再現方法

不具合を再現する方法を下記の例のように箇条書きで記述します。
1. ブラウザでURL '...' を開く

1. ブラウザで URL '...' を開く
2. '....' をクリックする
3. '....' までスクロールする
4. エラーが発生する

デプロイまでできており公開された URL で不具合が確認できる場合には URL も記載します。

## エラーログ

ブラウザの開発者コンソールと Vercel のコンソールで確認したエラーログを記載します。方法がわからない場合は wiki の「エラーログの確認方法」を参考にしてください。

## 期待する挙動

どのような挙動を期待しているかを明確かつ簡潔に記述します。

## スクリーンショット

エラーが発生している画面のスクリーンショットを添付します。

## リポジトリとブランチ名

もし Fork した easy-notion-blog でエラーが発生している場合には、あなたのリポジトリの URL とブランチ名を記載します。

## デスクトップ環境
- OS: [例 MacOS, Windows]
- ブラウザ: [例 Chrome, Safari]
- ブラウザのバージョン: [例 22]

- OS: [例 MacOS, Windows]
- ブラウザ: [例 Chrome, Safari]
- ブラウザのバージョン: [例 22]

## スマートフォン環境:
- デバイス: [例 iPhone6]
- OS: [例 iOS8.1]
- ブラウザ: [例 Chrome, Safari]
- ブラウザのバージョン [例 22]

- デバイス: [例 iPhone6]
- OS: [例 iOS8.1]
- ブラウザ: [例 Chrome, Safari]
- ブラウザのバージョン [例 22]

## 追加情報

他に伝えておくべき追加情報があれば記述します。
25 changes: 17 additions & 8 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

## Describe the bug

A clear and concise description of what the bug is.

## To Reproduce

Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -20,27 +22,34 @@ Steps to reproduce the behavior:
If you deployed and the bug is on the public URL, please write the URL.

## Error log

Error log is appeared in browser develper console and Vercel console

## Expected behavior

A clear and concise description of what you expected to happen.

## Screenshots

If applicable, add screenshots to help explain your problem.

## Repository and Branch

If you fork easy-notion-blog, please write your GitHub repository URL and branch.

## Desktop (please complete the following information)
- OS: [e.g. MacOS, Windows]
- Browser: [e.g. Chrome, Safari]
- Browser version: [e.g. 22]

- OS: [e.g. MacOS, Windows]
- Browser: [e.g. Chrome, Safari]
- Browser version: [e.g. 22]

## Smartphone (please complete the following information)
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser: [e.g. Chrome, Safari]
- Browser version: [e.g. 22]

- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser: [e.g. Chrome, Safari]
- Browser version: [e.g. 22]

## Additional context

Add any other context about the problem here.
2 changes: 1 addition & 1 deletion .github/pull.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "1"
version: '1'
rules:
- base: main
upstream: otoyo:main
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ jobs:
name: Kick deploy hook
runs-on: ubuntu-latest
steps:
- name: curl
run: curl -X POST '${{ secrets.DEPLOY_HOOK_URL }}'
- name: curl
run: curl -X POST '${{ secrets.DEPLOY_HOOK_URL }}'
25 changes: 25 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Format

on:
push:
branches:

jobs:
format:
name: Prettier
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v2

- uses: actions/setup-node@v1
with:
node-version: 16.x

- name: Run format
run: yarn format

- uses: stefanzweifel/[email protected]
with:
commit_message: Format by GitHub Actions
6 changes: 2 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: Lint

on:
pull_request:
types:
- opened
- reopened
push:
branches:

permissions:
checks: write
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ pnpm-debug.log*

tmp/
!tmp/.gitkeep

public/notion/*
!public/notion/.gitkeep
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/**/*
tmp/**/*
12 changes: 12 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"trailingComma": "es5",
"singleQuote": true,
"overrides": [
{
"files": ["*.ts", "*.astro"],
"options": {
"semi": false
}
}
]
}
19 changes: 9 additions & 10 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ astro-notion-blog を使えば [Notion](https://www.notion.so) で書けるブ
ブログは [Astro](https://astro.build/) を使って静的生成されるので非常に高速です。

- :rocket: ページの表示が**爆速**
- :pencil: **Notionで**ブログが書ける
- :pencil: **Notion で**ブログが書ける
- :hammer_and_wrench: ブログの見た目を**自由にカスタマイズ可能**
- :white_check_mark: **Notion 公式API**を使っているため安心
- :white_check_mark: **Notion 公式 API**を使っているため安心

## スクリーンショット

Expand All @@ -33,7 +33,7 @@ astro-notion-blog を使えば [Notion](https://www.notion.so) で書けるブ
### ステップ

1. このリポジトリを**スターします** :wink:
* スターしていただけると開発の励みになります
- スターしていただけると開発の励みになります
2. [ブログテンプレート](https://otoyo.notion.site/e2c5fa2e8660452988d6137ba57fd974?v=abe305cd8b3d467285e91a2a85f4d8de) を自分の Notion へ複製します
3. 複製したページ(データベース)の URL `https://notion.so/your-account/<ここ>?v=xxxx``DATABASE_ID` としてメモします

Expand All @@ -44,18 +44,18 @@ astro-notion-blog を使えば [Notion](https://www.notion.so) で書けるブ
4. [Create an integration](https://developers.notion.com/docs/create-a-notion-integration#step-1-create-an-integration) からインテグレーションを作成し "Internal Integration Token" を `NOTION_API_SECRET` としてメモします
5. 複製したページを再度開き [Share a database with your integration](https://developers.notion.com/docs/create-a-notion-integration#step-2-share-a-database-with-your-integration) の手順でインテグレーションにデータベースを共有します
6. このリポジトリを自分のアカウントヘフォークします
* フォークボタンは画面上部右側のスターの左にあります
- フォークボタンは画面上部右側のスターの左にあります
7. [Cloudflare Pages](https://pages.cloudflare.com/) を開きサインインします
* 言語設定を日本語に変更します
- 言語設定を日本語に変更します

<img src="https://user-images.githubusercontent.com/1063435/213967607-338b8728-d7c9-47e4-8192-e955e3f4ce30.png" width="220">

8. プロジェクトを "Connect to Git" を選んで作成し、先ほどフォークした `<your-account>/astro-notion-blog` リポジトリを選んで "Begin setup" をクリックします
9. 「ビルドの設定」で、
1. 「フレームワーク プリセット」でAstroを選択します
2. 「環境変数(アドバンスド)」 を開き `NODE_VERSION`, `NOTION_API_SECRET`, `DATABASE_ID` の3つを設定します
* `NODE_VERSION``v16.13.0` かそれ以上を指定します
* 詳しくは [How to deploy a site with Git](https://docs.astro.build/en/guides/deploy/cloudflare/#how-to-deploy-a-site-with-git) をご覧ください
1. 「フレームワーク プリセット」で Astro を選択します
2. 「環境変数(アドバンスド)」 を開き `NODE_VERSION`, `NOTION_API_SECRET`, `DATABASE_ID` の 3 つを設定します
- `NODE_VERSION``v16.13.0` かそれ以上を指定します
- 詳しくは [How to deploy a site with Git](https://docs.astro.build/en/guides/deploy/cloudflare/#how-to-deploy-a-site-with-git) をご覧ください

<img src="https://user-images.githubusercontent.com/1063435/213967111-72ea2ad1-ad3b-4629-8b65-7b25bc6ddb31.png" width="400">

Expand Down Expand Up @@ -114,4 +114,3 @@ Pull requests 歓迎です。
---

astro-notion-blog は [otoyo/notion-blog](https://github.com/otoyo/notion-blog) をベースにしています。

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The blog is generated statically by [Astro](https://astro.build/) so very fast.
### Steps

1. **Star this repo** :wink:
* It makes me motivative!
- It makes me motivative!
2. Duplicate [the blog template](https://otoyo.notion.site/e2c5fa2e8660452988d6137ba57fd974?v=abe305cd8b3d467285e91a2a85f4d8de) into your Notion.
3. Note the part of the page (database) URL `https://notion.so/your-account/<HERE>?v=xxxx` as `DATABASE_ID`

Expand All @@ -45,14 +45,14 @@ The blog is generated statically by [Astro](https://astro.build/) so very fast.
4. [Create an integration](https://developers.notion.com/docs/create-a-notion-integration#step-1-create-an-integration) and note "Internal Integration Token" as `NOTION_API_SECRET`
5. [Share a database with your integration](https://developers.notion.com/docs/create-a-notion-integration#step-2-share-a-database-with-your-integration) at the Notion database page
6. Fork this repository into your account
* The Fork button is at the top of the page and the left of the Star
- The Fork button is at the top of the page and the left of the Star
7. Go to [Cloudflare Pages](https://pages.cloudflare.com/) and sign in
8. Create new project with "Connect to Git" with your forked repository `<your-account>/astro-notion-blog`, then click "Begin setup"
9. In "Build settings" section,
1. Select "Astro" as "Framework preset"
2. Open "Environment Variables (advanced)" and set `NODE_VERSION`, `NOTION_API_SECRET` and `DATABASE_ID`
* `NODE_VERSION` is `v16.13.0` or higher
* [How to deploy a site with Git](https://docs.astro.build/en/guides/deploy/cloudflare/#how-to-deploy-a-site-with-git) is helpful
1. Select "Astro" as "Framework preset"
2. Open "Environment Variables (advanced)" and set `NODE_VERSION`, `NOTION_API_SECRET` and `DATABASE_ID`
- `NODE_VERSION` is `v16.13.0` or higher
- [How to deploy a site with Git](https://docs.astro.build/en/guides/deploy/cloudflare/#how-to-deploy-a-site-with-git) is helpful

<img src="https://user-images.githubusercontent.com/1063435/213967061-06f488fe-0b42-40a5-8f19-ac441f0168ff.png" width="400">

Expand Down
31 changes: 19 additions & 12 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
import { defineConfig } from 'astro/config'
import { defineConfig } from 'astro/config';
import { CUSTOM_DOMAIN, BASE_PATH } from './src/server-constants';
import FeaturedImageDownloader from './src/integrations/featured-image-downloader';
import PublicNotionCopier from './src/integrations/public-notion-copier';


const CUSTOM_DOMAIN = '' // <- Set your costom domain if you have. e.g. alpacat.com


const getSite = function() {
const getSite = function () {
if (!process.env.CF_PAGES) {
return 'http://localhost:3000'
return new URL(BASE_PATH, 'http://localhost:3000').toString();
}

if (process.env.CF_PAGES_BRANCH !== 'main') {
return process.env.CF_PAGES_URL
return new URL(BASE_PATH, process.env.CF_PAGES_URL).toString();
}

if (CUSTOM_DOMAIN) {
return `https://${CUSTOM_DOMAIN}`
return new URL(BASE_PATH, `https://${CUSTOM_DOMAIN}`).toString();
}

return `https://${new URL(process.env.CF_PAGES_URL).host.split('.').slice(1).join('.')}`
}
return new URL(
BASE_PATH,
`https://${new URL(process.env.CF_PAGES_URL).host
.split('.')
.slice(1)
.join('.')}`
).toString();
};

// https://astro.build/config
export default defineConfig({
site: getSite(),
})
base: BASE_PATH,
integrations: [FeaturedImageDownloader(), PublicNotionCopier()],
});
4 changes: 1 addition & 3 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
"default": {
"runner": "@nrwl/nx-cloud",
"options": {
"cacheableOperations": [
"_fetch-notion-blocks"
],
"cacheableOperations": ["_fetch-notion-blocks"],
"parallel": 8
}
}
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "astro-notion-blog",
"type": "module",
"version": "0.2.0",
"version": "0.3.0",
"private": true,
"scripts": {
"dev": "astro dev",
Expand All @@ -11,6 +11,7 @@
"preview": "astro preview",
"astro": "astro",
"lint": "eslint --ext .js,.ts,.astro src",
"format": "npx prettier --write .",
"cache:fetch": "node scripts/blog-contents-cache.cjs",
"cache:purge": "nx reset && rm -f tmp/*",
"_fetch-notion-blocks": "node scripts/retrieve-block-children.cjs"
Expand All @@ -20,13 +21,14 @@
"@astrojs/rss": "^2.0.0",
"@notionhq/client": "^2.2.3",
"@supercharge/promise-pool": "^2.3.2",
"astro": "^1.9.0",
"astro": "^2.0.10",
"katex": "^0.16.4",
"mermaid": "^9.3.0",
"metascraper": "^5.33.4",
"metascraper-description": "^5.33.4",
"metascraper-image": "^5.33.4",
"metascraper-title": "^5.33.4",
"node-fetch": "^3.3.0",
"prismjs": "^1.29.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
Empty file added public/notion/.gitkeep
Empty file.
Loading

0 comments on commit 37e955d

Please sign in to comment.