-
Couldn't load subscription status.
- Fork 40
feat: Option to take nav title from index.md front-matter title #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
It wasn't clear which checks were going to be ran in CI so I added a Makefile to make it more obvious. I'll take that out if it isn't desired. |
| resolved_children: list[NavPage | NavSection | NavLink] = resolve_in_priority_order(parsed_children, context) | ||
|
|
||
| return section_type(resolved_children, path=self.path, title=self._title) | ||
| title = self._resolved_title or dirname_to_title(self.path.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling dirname_to_title shouldn't be necessary here as it's already called by _generate_title
| context.visit(self._directory) | ||
|
|
||
| # Generate title if not already set | ||
| if self._resolved_title is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will always be true. I think you don't actually need two separate fields (_explicit_titleand _resolved_title).
I would revert back to _title and then do this:
if self._title is None:
self._title = self._generate_title(context)| @@ -0,0 +1,210 @@ | |||
| def test_use_index_title_disabled_by_default(mkdocs): | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you drop use_index_title_ from all the function titles? It's a bit redundant since it's already in the filename.
| - User Guide Documentation: user-guide/index.md | ||
| - Another page: user-guide/another-page.md | ||
| """ | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on the tests 👏
|
|
||
| To use the title from an `index.md` file as the directory navigation title: | ||
|
|
||
| ``` tab | `true` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be /// instead of the backticks to render correctly
| ??? tip "Interaction with other title settings" | ||
| - **Custom title**: A `title` set in `.nav.yml` always takes precedence over `use_index_title` | ||
| - **External title**: A title specified in the parent directory's `nav` configuration takes precedence | ||
| - **Preserve directory names**: When `preserve_directory_names: true` is set, it takes precedence over `use_index_title` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate you updating the docs as well 🙏
| @@ -0,0 +1,50 @@ | |||
| .PHONY: all help init clean test lint format type-check coverage | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer if you could remove the Makefile. Thanks for putting in the effort though!
I do see your point that it's difficult for contributors to know what they should run. I'll work on improving that 👍
|
@lukasgeiter Thanks for the feedback! It's been a long week but I will get back to this eventually and clean it up. |
|
@sharp-bits Soon? 🙏 We would love this feature |
Provide use_index_title option within .nav.yml which will use the title defined in the index.md frontmatter as the nav title. This is the behavior we expected when transitioning from JTD and this is a preferable option to renaming all the directories.
Fixes #61 and also provides a better solution for mkdocs #2086
(Thanks for the awesome plugin)