66from sphinx .util .docutils import SphinxDirective
77
88from .icons import get_octicon
9- from .shared import create_component
9+ from .shared import SEMANTIC_COLORS , create_component , make_choice
1010
1111
1212def setup_article_info (app : Sphinx ):
@@ -24,10 +24,12 @@ class ArticleInfoDirective(SphinxDirective):
2424 "avatar" : directives .uri ,
2525 "avatar-alt" : directives .unchanged ,
2626 "avatar-link" : directives .uri ,
27+ "avatar-outline" : make_choice (SEMANTIC_COLORS ),
2728 "author" : directives .unchanged_required ,
2829 "date" : directives .unchanged_required ,
2930 "read-time" : directives .unchanged_required ,
30- "class" : directives .class_option ,
31+ "class-container" : directives .class_option ,
32+ "class-avatar" : directives .class_option ,
3133 }
3234
3335 def _parse_text (
@@ -59,17 +61,13 @@ def run(self) -> List[nodes.Node]:
5961 "sd-mt-2" ,
6062 "sd-mb-4" ,
6163 ]
62- + self .options .get ("class" , []),
64+ + self .options .get ("class-container " , []),
6365 )
6466 self .set_source_info (top_grid )
6567
6668 top_row = create_component (
6769 "grid-row" ,
68- [
69- "sd-row" ,
70- "sd-row-cols-2" ,
71- "sd-g-1" ,
72- ],
70+ ["sd-row" , "sd-row-cols-2" , "sd-gx-2" , "sd-gy-1" ],
7371 )
7472 self .set_source_info (top_row )
7573 top_grid += top_row
@@ -82,11 +80,16 @@ def run(self) -> List[nodes.Node]:
8280 ["sd-col" , "sd-col-auto" , "sd-d-flex" , "sd-align-items-center" ],
8381 )
8482 self .set_source_info (avatar_column )
83+ avatar_classes = ["sd-avatar-sm" ]
84+ if "avatar-outline" in self .options :
85+ avatar_classes .append (f"sd-outline-{ self .options ['avatar-outline' ]} " )
86+ if "class-avatar" in self .options :
87+ avatar_classes += self .options ["class-avatar" ]
8588 avatar_image = nodes .image (
8689 "" ,
8790 uri = avatar_uri ,
8891 alt = self .options .get ("avatar-alt" , "" ),
89- classes = [ "sd-avatar-sm" ] ,
92+ classes = avatar_classes ,
9093 )
9194 self .set_source_info (avatar_image )
9295 if self .options .get ("avatar-link" ):
0 commit comments