Skip to content
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
90 changes: 84 additions & 6 deletions contents/books.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
- id: lunyu
name: 論語
compositionYear: -479 # 孔子没後、弟子たちが編纂
sectionLabel: 篇
totalSections: 20
sections:
- id: '1'
Expand Down Expand Up @@ -67,6 +68,7 @@
- id: mengzi
name: 孟子
compositionYear: -300 # 孟子の弟子たちが編纂
sectionLabel: 篇
totalSections: 14
sections:
- id: '1'
Expand Down Expand Up @@ -115,25 +117,97 @@
- id: daxue
name: 大学
compositionYear: -450 # 曾子の作とされる
totalSections: 1
sectionLabel: 章
totalSections: 6
sections:
- id: '1'
name: 大学
totalChapters: 11
name: 第一章
totalChapters: 3
- id: '2'
name: 第二章
totalChapters: 4
- id: '3'
name: 第三章
totalChapters: 1
- id: '4'
name: 第四章
totalChapters: 1
- id: '5'
name: 第五章
totalChapters: 2
- id: '6'
name: 第六章
totalChapters: 4

Comment on lines 117 to 141

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the directory structure under contents/input/daxue/
echo "=== daxue directory structure ==="
fd . contents/input/daxue/ --type f 2>/dev/null || echo "No daxue input directory found"
echo ""
echo "=== zhongyong directory structure ==="
fd . contents/input/zhongyong/ --type f 2>/dev/null || echo "No zhongyong input directory found"

Repository: Rindrics/izuminokami-kanesada

Length of output: 209


Input directory structure does not match the new daxue and zhongyong section definitions.

The YAML defines daxue with 6 sections and zhongyong with 19 sections, but the input directories contain only contents/input/daxue/1/1.yaml and contents/input/zhongyong/1/1.yaml. The content generation script will not find files for sections 2-6 (daxue) and 2-19 (zhongyong), leaving these sections empty. Reorganize the input files to match the new section structure: contents/input/daxue/1/, contents/input/daxue/2/, ..., contents/input/daxue/6/ and similarly for zhongyong.

🤖 Prompt for AI Agents
In `@contents/books.yaml` around lines 117 - 141, The books.yaml defines daxue
with six sections and zhongyong with nineteen, but the input content only exists
under contents/input/daxue/1/1.yaml and contents/input/zhongyong/1/1.yaml; fix
by reorganizing the input directory structure to match those section
definitions: create directories contents/input/daxue/2 through
contents/input/daxue/6 and contents/input/zhongyong/2 through
contents/input/zhongyong/19, then move or split the appropriate chapter YAML
files into each section directory so that each section directory contains its
chapter files (e.g., contents/input/daxue/3/1.yaml for daxue section id '3');
ensure file names and IDs match the section ids listed in books.yaml so the
content generator can find files for functions/process that read those paths.

- id: zhongyong
name: 中庸
compositionYear: -430 # 子思の作とされる
totalSections: 1
sectionLabel: 章
totalSections: 19
Comment on lines +120 to +146

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. Daxue/zhongyong still sectioned 📎 Requirement gap ✓ Correctness

大学・中庸について、section無し(または空セクション)で章を扱える形(A案/B案)になっておらず、複数の命名セクションを導入しています. This does not meet the
checklist requirement that UI should be able to treat them as having no sections (or an empty
section) without inconsistency.
Agent Prompt
## Issue description
大学・中庸の構造が、要件で提示された A案(section無し)/B案(空セクションをUI上section無し扱い)のどちらにもなっておらず、複数の命名セクションを作っています。

## Issue Context
PR Compliance ID 8 は、大学・中庸を「sectionなしでも章を扱える」か「空セクションでUI上はsection無し表示」にすることを求めています。

## Fix Focus Areas
- contents/books.yaml[117-146]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

sections:
- id: '1'
name: 中庸
totalChapters: 33
name: 第一章
totalChapters: 1
- id: '2'
name: 第二章
totalChapters: 1
- id: '3'
name: 第三章
totalChapters: 1
- id: '4'
name: 第四章
totalChapters: 1
- id: '5'
name: 第五章
totalChapters: 1
- id: '6'
name: 第六章
totalChapters: 1
- id: '7'
name: 第七章
totalChapters: 1
- id: '8'
name: 第八章
totalChapters: 1
- id: '9'
name: 第九章
totalChapters: 1
- id: '10'
name: 第十章
totalChapters: 1
- id: '11'
name: 第十一章
totalChapters: 1
- id: '12'
name: 第十二章
totalChapters: 1
- id: '13'
name: 第十三章
totalChapters: 1
- id: '14'
name: 第十四章
totalChapters: 1
- id: '15'
name: 第十五章
totalChapters: 1
- id: '16'
name: 第十六章
totalChapters: 1
- id: '17'
name: 第十七章
totalChapters: 1
- id: '18'
name: 第十八章
totalChapters: 1
- id: '19'
name: 第十九章
totalChapters: 1

# 五経

- id: yijing
name: 易経
sectionLabel: 経
totalSections: 2
sections:
- id: '1'
Expand All @@ -145,6 +219,7 @@

- id: shujing
name: 書経
sectionLabel: 篇
totalSections: 4
sections:
- id: '1'
Expand All @@ -162,6 +237,7 @@

- id: shijing
name: 詩経
sectionLabel: 篇
totalSections: 4
sections:
- id: '1'
Expand All @@ -179,6 +255,7 @@

- id: liji
name: 礼記
sectionLabel: 篇

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. liji section name redundant 📎 Requirement gap ✓ Correctness

liji is still defined with a single section whose name equals book.name, which can keep the
redundant UI hierarchy (e.g., 礼記 → 礼記 → ...). This does not satisfy the requirement to eliminate
consecutive book.name/section.name duplication for 礼記.
Agent Prompt
## Issue description
`liji`(礼記)が単一セクションかつ `section.name === book.name` のため、UIで `礼記 → 礼記 → ...` の冗長な階層表示が発生し得ます。

## Issue Context
PR Compliance ID 7 では、大学・中庸・礼記において `book.name` と同文言の `section` が連続表示されないことが要件です。

## Fix Focus Areas
- contents/books.yaml[256-263]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

totalSections: 1
sections:
- id: '1'
Expand All @@ -187,6 +264,7 @@

- id: chunqiu
name: 春秋左氏伝
sectionLabel: 篇
totalSections: 12
sections:
- id: '1'
Expand Down
3 changes: 3 additions & 0 deletions scripts/generate-contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ interface InputBook {
id: string;
name: string;
compositionYear?: number;
sectionLabel?: string;
totalSections: number;
sections: InputSection[];
}
Expand All @@ -102,6 +103,7 @@ interface OutputBook {
id: string;
name: string;
compositionYear?: number;
sectionLabel?: string;
totalSections: number;
sections: OutputSection[];
}
Expand Down Expand Up @@ -1345,6 +1347,7 @@ export function getAdjacentContentIds(
id: book.id,
name: book.name,
compositionYear: book.compositionYear,
sectionLabel: book.sectionLabel,
totalSections: book.totalSections,
sections: book.sections.map((section) => ({
id: section.id,
Expand Down
14 changes: 10 additions & 4 deletions src/app/books/[bookId]/[sectionId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
const section = getSectionById(bookId, sectionId);

if (!book || !section) {
return { title: '編が見つかりません' };
return { title: 'セクションが見つかりません' };
}

const sectionLabel = book.sectionLabel ?? '編';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Unused variable sectionLabel in generateMetadata.

sectionLabel is declared on Line 39 but never referenced in the description or title construction (Lines 40–41). Either remove it or incorporate it into the description if that was the intent.

🔧 Remove unused variable
-  const sectionLabel = book.sectionLabel ?? '編';
   const title = `${section.name} - ${book.name}`;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const sectionLabel = book.sectionLabel ?? '編';
const title = `${section.name} - ${book.name}`;
🤖 Prompt for AI Agents
In `@src/app/books/`[bookId]/[sectionId]/page.tsx at line 39, In generateMetadata,
the local variable sectionLabel (declared as const sectionLabel =
book.sectionLabel ?? '編') is unused; either remove that declaration from
generateMetadata or use sectionLabel when building the title/description (e.g.,
incorporate sectionLabel into the title/description construction where
book.title and sectionTitle are combined). Update the generateMetadata function
to reference sectionLabel (or delete the const) so there are no unused
variables.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

3. Unused sectionlabel in metadata 🐞 Bug ⛯ Reliability

generateMetadata in the section page declares sectionLabel but never uses it. With Biome linter
enabled (recommended rules) and CI running biome check src, this will fail lint and block
merges/builds.
Agent Prompt
### Issue description
`src/app/books/[bookId]/[sectionId]/page.tsx` defines `sectionLabel` inside `generateMetadata`, but the variable is unused. With Biome recommended lint rules enabled and CI running `biome check src`, this will fail lint.

### Issue Context
`sectionLabel` is used later in the page component for prev/next labels, but not in the `generateMetadata` function scope.

### Fix Focus Areas
- src/app/books/[bookId]/[sectionId]/page.tsx[30-47]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

const title = `${section.name} - ${book.name}`;
const description = `${book.name} ${section.name}の全章を一覧表示。現在${section.chapters.length}/${section.totalChapters}章を収録。孔子の教えを白文と訓読みで学習できます。`;
const description = `${book.name} ${section.name}の全章を一覧表示。現在${section.chapters.length}/${section.totalChapters}章を収録。白文と訓読みで学習できます。`;

return createMetadata({
title,
Expand All @@ -63,8 +64,13 @@ export default async function SectionPage({ params }: Props) {
const prevUrl = prevSection ? `/books/${bookId}/${prev}` : null;
const nextUrl = nextSection ? `/books/${bookId}/${next}` : null;

const prevLabel = prevSection ? `前の編(${prevSection.name})へ` : undefined;
const nextLabel = nextSection ? `次の編(${nextSection.name})へ` : undefined;
const sectionLabel = book.sectionLabel ?? '編';
const prevLabel = prevSection
? `前の${sectionLabel}(${prevSection.name})へ`
: undefined;
const nextLabel = nextSection
? `次の${sectionLabel}(${nextSection.name})へ`
: undefined;

return (
<PageWithSidebar showSidebar={false}>
Expand Down
5 changes: 3 additions & 2 deletions src/app/books/[bookId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
return { title: '書籍が見つかりません' };
}

const sectionLabel = book.sectionLabel ?? '編';
const currentSections = book.sections.filter(
(s) => s.chapters.length > 0,
).length;
Expand All @@ -36,7 +37,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
);

const title = book.name;
const description = `${book.name}の全編を一覧表示。現在${currentSections}/${book.totalSections}、計${currentChapters}章を収録。白文・訓読み・読み下し文で学習できます。`;
const description = `${book.name}の全${sectionLabel}を一覧表示。現在${currentSections}/${book.totalSections}${sectionLabel}、計${currentChapters}章を収録。白文・訓読み・読み下し文で学習できます。`;

return createMetadata({
title,
Expand Down Expand Up @@ -116,7 +117,7 @@ export default async function BookPage({ params }: Props) {

<section>
<h2 className="mb-4 text-lg font-medium text-zinc-600 dark:text-zinc-400">
編一覧
{book.sectionLabel ?? '編'}一覧
</h2>
<ListWithFavoriteSidebar>
<ul className="space-y-2">
Expand Down
5 changes: 3 additions & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ export default function Home() {
);
const hasContent = currentChapters > 0;
const isSingleSection = book.totalSections === 1;
const sectionLabel = book.sectionLabel ?? '編';

const progressText = isSingleSection
? `${currentChapters}/${totalChapters}章`
: `${currentSections}/${book.totalSections}、計${currentChapters}章`;
: `${currentSections}/${book.totalSections}${sectionLabel}、計${currentChapters}章`;

const disabledText = isSingleSection
? `0/${totalChapters}章`
: `0/${book.totalSections}`;
: `0/${book.totalSections}${sectionLabel}`;

return (
<li key={book.id}>
Expand Down
1 change: 1 addition & 0 deletions src/types/book.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface Book {
id: string; // "lunyu"
name: string; // "論語"
compositionYear?: number; // Year of composition (negative for BCE, e.g., -479)
sectionLabel?: string; // Display label for sections (e.g., "編", "章", "篇")
totalSections: number; // Total number of sections in the book (e.g., 20 for Lunyu)
sections: Section[];
}
Expand Down