File tree Expand file tree Collapse file tree 1 file changed +21
-9
lines changed Expand file tree Collapse file tree 1 file changed +21
-9
lines changed Original file line number Diff line number Diff line change 11import uuid
22from datetime import datetime , timezone
3+ from urllib .parse import parse_qs , urlparse
34
45import requests
56import spdx_lookup as lookup
@@ -321,15 +322,26 @@ def add_collection_information(
321322 roles = ["metadata" ],
322323 ),
323324 )
324- if collection_config .get ("Story" ):
325- collection .add_asset (
326- "story" ,
327- Asset (
328- href = f'{ catalog_config ["assets_endpoint" ]} /{ collection_config ["Story" ]} ' ,
329- media_type = "text/markdown" ,
330- roles = ["metadata" ],
331- ),
332- )
325+ if stories := collection_config .get ("Stories" ):
326+ for story in stories :
327+ if story .startswith ("http" ):
328+ story_url = story
329+ else :
330+ story_url = f'{ catalog_config .get ("stories_endpoint" )} /{ story } '
331+ parsed_url = urlparse (story_url )
332+ # check if it is URL with a query parameter id=story-identifier
333+ if parsed_url .query and len (parse_qs (parsed_url .query ).get ("id" )) > 0 :
334+ story_id = parse_qs (parsed_url .query ).get ("id" )[0 ]
335+ else :
336+ story_id = parsed_url .path .rsplit ("/" )[- 1 ].replace (".md" , "" ).replace (".MD" , "" )
337+ collection .add_asset (
338+ story_id ,
339+ Asset (
340+ href = story_url ,
341+ media_type = "text/markdown" ,
342+ roles = ["metadata" , "story" ],
343+ ),
344+ )
333345 if collection_config .get ("Image" ):
334346 # Check if absolute URL or relative path
335347 if collection_config ["Image" ].startswith ("http" ):
You can’t perform that action at this time.
0 commit comments