Repository navigation
Conversation
- Qiita / Zenn は記事ページの OGP と JSON-LD、Medium は公式 RSS から取得する - 取得先は Qiita / Zenn / Medium のドメインに限り、リダイレクト先も確かめる (SSRF 対策) - 自動で入れた値は記事URLを変えたら消し、手で入れた値は残す - 取得中は登録ボタンを押せないようにする Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Deployed on https://dev-pr-355-birbz3fm6q-an.a.run.app |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
Closes #354
記事管理ページ (
/internal/blogs) で記事URLを入力すると、タイトル・説明・公開日・媒体・サムネイル画像URLを自動で入力するようにしました。入力された値はそのまま書き換えられます。自動で取れない媒体 (「その他」) や項目は、これまでどおり手動で入力します。媒体ごとに自動で入る項目
og:title(末尾の「 - Qiita」は削る)og:titleog:description(本文の冒頭)datePublishedpubDateog:imageog:imagemedium.com/feed/@ユーザー名など) を使っています。RSS に載るのは直近 10 件程度なので、古い記事は取れず手動入力になります (媒体だけはドメインから入ります)。変更内容
lib/blog-metadata.ts: 記事URLから情報を取得する処理 (サーバー側)redirect: "manual"で 1 回ずつ追い、行き先が許可ドメインでない・https でないときは打ち切る (最大 3 回)app/api/blogs/metadata/route.ts: 上記を呼ぶ API。ログイン済み・未退会のメンバーだけが使える。取れなかったときも 200 でmetadata: nulllib/blog-autofill.ts: フォームのどの欄に入れるか / いつ消すかを決める純粋関数components/blogs/blog-manager.tsx:テスト
lib/blog-metadata.test.ts/lib/blog-autofill.test.tsを追加 (43 件)qiita.com.evil.example、evilmedium.com)、http、許可外へのリダイレクト、リダイレクトの上限、2MB 超の本文、タイムアウト、タイトル末尾の媒体名の削り方、日本時間への変換 (UTC で日付がずれる時刻)、手で入れた値を消さないこと など/blogs) での表示まで確認スクリーンショット (ローカル)
Qiita の記事URLを入力してフォーカスを外すと、各項目が自動で入る
登録後、公開一覧 (
/blogs) にサムネイル付きで表示される (右は Medium の記事)🤖 Generated with Claude Code