@@ -94,14 +94,20 @@ def sortChildren(self):
9494 def get (self , tag : str ):
9595 return self .tags .get (tag )
9696 def __iter__ (self ):
97- return iter (self .tags .values ())
97+ for filename in config ['collections' ]['tags' ]['order' ]:
98+ yield self .tags [filename [:- 3 ]]
9899 def __len__ (self ):
99100 return len (self .tags )
100101 def __contains__ (self , item ):
101102 if isinstance (item , TagFile ):
102103 return item .slug in self .tags
103104 return bool (self .get (item ))
104105
106+ content = []
107+ tags = TagCollection ()
108+ authors = AuthorCollection ()
109+ courses = []
110+
105111class ContentFile (JekyllFile ):
106112 def __init__ (self , fd : Path , content , handler = None , ** kwargs ) -> None :
107113 fd = Path (fd )
@@ -138,9 +144,19 @@ def external_url_linkfmt(self):
138144 return "YouTube (link)"
139145 return ""
140146
141- content = []
142- tags = TagCollection ()
143- authors = AuthorCollection ()
147+ def primarytag_ordinality (self ) -> tuple [str , int ]:
148+ """Mirrors the logic of _include/content_primarytag_ordinality.liquid"""
149+ if self .course :
150+ for idx , candidatecourse in enumerate (courses ):
151+ if self .course == candidatecourse .slug :
152+ return (self .course , idx )
153+ for idx , candidatetag in enumerate (tags ):
154+ if candidatetag .slug == self .course :
155+ return (self .course , idx + len (courses ))
156+ for idx , candidatetag in enumerate (tags ):
157+ if candidatetag .slug in self .tags :
158+ return (candidatetag .slug , idx + len (courses ))
159+ return (False , 9999 )
144160
145161def entry_with_drive_id (gid ):
146162 for entry in content :
@@ -174,6 +190,9 @@ def load():
174190 if content :
175191 return
176192 filecreationtimes .update (get_file_creation_times ())
193+ for filepath in root_folder .joinpath ("_courses" ).rglob ("*.md" ):
194+ courses .append (JekyllFile .load (filepath ))
195+ courses .sort (key = lambda c : c .created_at )
177196 for contentfolder in root_folder .joinpath ('_content' ).iterdir ():
178197 if (not contentfolder .is_dir ()) or contentfolder .name .startswith ('.' ):
179198 continue
0 commit comments