-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add support for mapping blog directory. Set blog directory to 'blog' #14483
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
Conversation
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.
Sounds good to fix the issue, but I also have a couple of questions/comments.
val blogDirectory = yamlRoot.nested.collect { | ||
case blog @ Sidebar.Category(optionTitle, optionIndexPath, nested, dir) | ||
if optionTitle.exists(_ == "Blog") => blog | ||
}.headOption.flatMap(_.directory) |
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.
FYI, you could use find
instead of collect
+ headOption
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.
Or, maybe it could improve maintainability to use partitionWith
to compute both blogDirectory
and rootChildrenWithoutBlog
at the same time?
type Date = (String, String, String) | ||
val destDirectory = directory.getOrElse("_blog") |
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 find it weird to use _blog
as a default target directory. I would rather use just blog
instead, what do you think?
@@ -51,6 +53,7 @@ object Sidebar: | |||
| subsection: # optional - If not provided, pages are loaded from the index directory | |||
| - <subsection> | <page> | |||
| # either index or subsection needs to be present | |||
| # the only exception is subsection representing Blog which needs title == "Blog" and directory |
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.
What do you think of relaxing the requirement of providing a directory
(and using blog
as a default value)?
What happens if someone creates a directory _blog
but no entry title: Blog
in the sidebar? Conversely, is it possible to create an entry with title: Blog
and index: _news/index.html
, for instance (to read the blog posts from the _news
directory)?
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.
There I also have some doubts. It's nice to be able to map blog directory but on the other hand it creates additional complexity to configuration. My idea was to generate blog regardless of presence Blog subsection in YAML (The only condition would be existence of "_blog" directory) but it might be misleading since we use YAML to define which static sites appear. I see two solutions here:
- We remove changes that I've made here and only change blog directory to "blog"
- We handle Blog as a special subsection where we can provide output directory for blog (and maybe the input directory?) but I feel like Blog is a special element in static site and it's not trivial to implement this solution without increasing complexity of logic.
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 think it’s good to allow the users to define the blog entry in their sidebar so that they can control where it appears in the navigation menu. Yes, the blog is a special entry. Maybe it requires a special AST node as well to make this clearer in the logic?
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.
Do you think we should control whether blog should be rendered with yaml config?
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 think for now we should just repair dotty.epfl.ch (implement the second solution) and create an issue about customizing Blog with YAML. Especially since we want to make the default blog directory to 'blog'.
For now, we just fix the dotty.epfl.ch in: #14485 |
related to: #1342