This is an automated email from the ASF dual-hosted git repository.
niallp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/attic.git
The following commit(s) were added to refs/heads/main by this push:
new d84cbfe Fix the project order in the Navigation sidebar: - projects
with lowercase names (e.g. iBATIS) were at the end of the list - add
lowercase name and sort project list on that - add "nav_order" to page
attributes using index of the sorted project list
d84cbfe is described below
commit d84cbfee1ea047db75fab664ca98ad4fd08a243f
Author: Niall Pemberton <[email protected]>
AuthorDate: Thu May 1 03:32:38 2025 +0100
Fix the project order in the Navigation sidebar:
- projects with lowercase names (e.g. iBATIS) were at the end of the list
- add lowercase name and sort project list on that
- add "nav_order" to page attributes using index of the sorted project
list
---
_plugins/project-data-plugin.rb | 3 ++-
_plugins/projects-plugin.rb | 13 +++++++------
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/_plugins/project-data-plugin.rb b/_plugins/project-data-plugin.rb
index 84e319d..ad181e2 100644
--- a/_plugins/project-data-plugin.rb
+++ b/_plugins/project-data-plugin.rb
@@ -36,6 +36,7 @@ module ProjectDataPlugin
site.data['projects'].each do | projectId, project|
project['project_id'] = projectId
project['project_name'] = project.fetch("project_name",
projectId.capitalize())
+ project['project_name_lower'] = project["project_name"].downcase
project['project_longname'] = project.fetch("project_longname",
project['project_name'] )
project['project_apachename'] = "Apache " + project["project_longname"]
project['project_domain'] = project.fetch("project_domain", projectId
+ ".apache.org")
@@ -60,7 +61,7 @@ module ProjectDataPlugin
projects.push(project)
end
- site.data['project_array'] = projects
+ site.data['project_array'] = projects.sort_by { |project|
project['project_name_lower'] }
end
end
diff --git a/_plugins/projects-plugin.rb b/_plugins/projects-plugin.rb
index 7d8b80a..30d5da5 100644
--- a/_plugins/projects-plugin.rb
+++ b/_plugins/projects-plugin.rb
@@ -26,8 +26,8 @@ module ProjectsPlugin
safe true
def generate(site)
- site.data['project_array'].each do | project |
- site.pages << ProjectPage.new(site, project['project_id'], project)
+ site.data['project_array'].each_with_index do | project, index |
+ site.pages << ProjectPage.new(site, index, project)
end
end
end
@@ -37,16 +37,16 @@ module ProjectsPlugin
#
# Subclass of `Jekyll::Page` with custom method definitions.
class ProjectPage < Jekyll::Page
- def initialize(site, projectId, project)
+ def initialize(site, index, project)
@site = site # the current site instance.
@base = site.source # path to the source directory.
@dir = 'projects' # the directory the page will reside in.
# Page name
- @basename = projectId # filename without the extension.
- @ext = '.html' # the extension.
- @name = @basename + @ext # filename
+ @basename = project['project_id'] # filename without the extension.
+ @ext = '.html' # the extension.
+ @name = @basename + @ext # filename
# Look up front matter defaults scoped to type `categories`, if given key
# doesn't exist in the `data` hash.
@@ -58,6 +58,7 @@ module ProjectsPlugin
@data['layout'] ='project-layout'
@data['title'] = project['project_name']
@data['parent'] = 'Retired Projects'
+ @data['nav_order'] = index
@data['has_toc'] = true
end
end