(category: str, meta: dict[str, str], article_map: dict[str, dict[str, str]])
| 348 | |
| 349 | |
| 350 | def write_category_index(category: str, meta: dict[str, str], article_map: dict[str, dict[str, str]]) -> None: |
| 351 | lines = [ |
| 352 | f"# {meta['title']}", |
| 353 | "", |
| 354 | meta["description"], |
| 355 | "", |
| 356 | ] |
| 357 | source_items = parse_index_items(SOURCE_ROOT / category / "README.md") |
| 358 | for date, _title, href in source_items: |
| 359 | source_path = (SOURCE_ROOT / category / unquote(href.split("?")[0].split("#")[0].replace("./", ""))).resolve() |
| 360 | source_rel = source_path.relative_to(ROOT).as_posix() |
| 361 | mapped = article_map.get(source_rel) |
| 362 | if not mapped: |
| 363 | continue |
| 364 | file_name = Path(mapped["english_path"]).name |
| 365 | lines.append(f"- {date} - [{mapped['english_title']}](./{file_name})") |
| 366 | |
| 367 | lines.extend(["", '<p class="branch-back"><a href="#/en/ai-articles/README">Back</a></p>', ""]) |
| 368 | (TARGET_ROOT / category / "README.md").write_text("\n".join(lines), encoding="utf-8") |
| 369 | |
| 370 | |
| 371 | def update_english_readme_links(article_map: dict[str, dict[str, str]]) -> None: |
no test coverage detected