Chapters in files instead of in directories#200
Open
janezd wants to merge 2 commits intobiolab:masterfrom
Open
Chapters in files instead of in directories#200janezd wants to merge 2 commits intobiolab:masterfrom
janezd wants to merge 2 commits intobiolab:masterfrom
Conversation
There was a problem hiding this comment.
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
chapterDirtochapterPathin type definitions and throughout the codebase to support both file and directory chapter specifications - Enhanced
getMdFileto directly return paths that end with.mdor.mdx - Added logic in
serializedContentto extract the directory path from file paths for resolving relative resource links - Renamed
addRelativePathplugin toaddRelativeDirto 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.
59f044d to
0bc2632
Compare
Refactoring: Rename chapterDir to chapterPath.
0bc2632 to
571311e
Compare
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.
@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.mdis 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.