Skip to content

Chapters in files instead of in directories#200

Open
janezd wants to merge 2 commits intobiolab:masterfrom
janezd:allow-chapters-in-files
Open

Chapters in files instead of in directories#200
janezd wants to merge 2 commits intobiolab:masterfrom
janezd:allow-chapters-in-files

Conversation

@janezd
Copy link
Contributor

@janezd janezd commented Feb 25, 2026

@markotoplak will like this. (Thanks for the suggestion, I didn't realize that I also want to have this.)

With this PR, you can give chapters as file names instead of directories. The name can be anything relative to the book directory. E.g. file-structure/index.md is equivalent to the existing ./file-structure. A common use will, of course, be files in the book's directory, e.g. some-chapter.md. Mixing styles is allowed.

---
title: Content Creation
chapters:
- ./file-structure
- collection_.md
- book.md
- ./images
- ./extra-styling
- question.md
---

@janezd janezd changed the title Implement chapters in files instead of in directories Chapters in files instead of in directories Feb 25, 2026
@janezd janezd requested a review from Copilot February 25, 2026 20:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the chapter specification functionality to allow chapters to be defined as file paths (ending in .md or .mdx) in addition to the existing directory-based approach. The main change is renaming chapterDir to chapterPath throughout the codebase to reflect this more flexible approach. The PR also includes supporting logic to distinguish between file paths and directory paths when resolving relative directories for resource links.

Changes:

  • Renamed chapterDir to chapterPath in type definitions and throughout the codebase to support both file and directory chapter specifications
  • Enhanced getMdFile to directly return paths that end with .md or .mdx
  • Added logic in serializedContent to extract the directory path from file paths for resolving relative resource links
  • Renamed addRelativePath plugin to addRelativeDir to better reflect its purpose

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
types/index.ts Renamed chapterDir to chapterPath in ChapterDefBase interface
ingest/book.ts Updated path resolution logic to support file-based chapters; renamed all references from chapterDir to chapterPath
ingest/md-helpers.ts Enhanced getMdFile to handle direct file paths; added directory extraction logic in serializedContent for file paths
ingest/plugins.ts Renamed addRelativePath to addRelativeDir for clarity
ingest/updatePaths.ts Updated all database operations to use chapterPath instead of chapterDir
components/Book/Book.tsx Updated React key from chapterDir to chapterPath
api/book.ts Updated data mapping from database to use chapterPath

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@janezd janezd force-pushed the allow-chapters-in-files branch from 59f044d to 0bc2632 Compare February 25, 2026 20:32
@janezd janezd force-pushed the allow-chapters-in-files branch from 0bc2632 to 571311e Compare March 2, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants