Replies: 2 comments 2 replies
-
Why not create one proposal issue per thing you want to contribute? Discussing 7 things in a single issue is only going to create a mess, and not a good idea. Otherwise, some of those changes look like possible things we'd want to add to Docusaurus yes. |
Beta Was this translation helpful? Give feedback.
2 replies
-
Separate issues were added for each new feature. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For the needs of a project (multiple blog instances, with historical data), I had to do a fork and add several enhancements, mainly related to grouping and sorting.
The fork is available at https://github.com/cronica-it/docusaurus-chronology.
The updated code is in the
development
branch, while the original code remains in themain
branch.The changes, mainly enhancements, are enabled via configuration options, and the defaults should not affect the functionality of the standard Docusaurus project.
The enhancements are listed below.
Generate grouping pages by Authors, similarly to Tags
For blogs with multiple authors, it is useful to view the pages contributed by each author.
Similarly to the Tags grouping pages, pages to group posts by authors can now be generated.
Links to authors are also added at the bottom of the posts, after the links to tags:
A new configuration option
generateAuthorsPages
was added; when set to true, the authors pages are generated asblog/authors
andblog/authors/${name}
.Note: Docusaurus allows to define authors identified by a picture, without having to enter the name; these nameless authors are filtered out and not indexed in the Authors pages.
Add
showLastUpdateTime
andshowLastUpdateAuthor
to blog postsIn some cases, for example sites with research data, the content of the posts is expected to be updated from time to time, as new data is discovered.
To help users identify the updated content, it is useful to know the last updated time and provide a way to order post by it.
The mechanism of computing the last updated time is based on the latest git commit time, similarly to the mechanism used for docs; it is enabled by the same configuration options,
showLastUpdateTime
andshowLastUpdateAuthor
.When enabled, the last update time is displayed below the post and also used when sorting the posts in the feed files.
Add
sortSidebarByLastUpdate
to change the order in the sidebarWhen posts are edited and the retrieving the date of the last update is enabled, it also makes sense to show the updated posts in the top of the sidebar list.
A new configuration option
sortSidebarByLastUpdate
was added; when set to true, the sidebar list is sorted by the last update time, when available.Hide redundant year in dates shown in the Archive page
In the Archive page, when listing the the post titles grouped by years, there is not need to show the year again, since it is redundant.
For aesthetic reasons, a new configuration option
hidePostYearInArchive
was added; when set to true, the date format is adjusted to no longer show the year.Improve support for posts related to events in the past
The common use case for blogs is to document recent events; in other words, the post date and the event date are more or less the same.
For blogs documenting historical events, the post date remains in the present, as for regular posts, but the event date is in the past, and should be entered as a separate frontMatter string property.
Since some historical events do not have an exact date, this property can be incomplete, without day or even without month, for example:
For events that lasted more than one day, it is possible to also define the end date, as a string with the similar incomplete syntax:
To enable this feature, a new configuration option
sortPostsByEventDate
was added; when set to true, the event dates are parsed and used when sorting the posts in the Archive page, so the years of past events are located at the end.Add
pageBasePath
to blog plugin configurationIn Docusaurus, the URL parts used to compose the pages paths are configurable via options like
routeBasePath
,tagsBasePath
, etc, but in the path used for multi-page lists, a part of the URL is hard-coded aspage
.For consistency reasons, a new configuration option was added,
pageBasePath
, allowing to also configure this path, a feature useful for example when all paths are translated to local languages.Apply
applyTrailingSlash
to feed URLsThe
trailingSlash
configuration is available to customize the presence/absence of a trailing slash at the end of URLs; unfortunately this setting does not apply to the links generated in the feed files, and tools like Algolia that use the files may behave unusual.Thus, the
applyTrailingSlash
function is called to conditionally adjust the URLs generated in the feed files.I'd be glad to see these changes contributed back to the upstream project.
So, if there is interest in any of these features, please feel free to use my code as a starting point and possibly improve it.
I can also prepare separate PRs, if needed.
Beta Was this translation helpful? Give feedback.
All reactions