去掉 Astro 专用 frontmatter 字段,只保留 title 和 pubDate。
(content)
| 620 | |
| 621 | |
| 622 | def _strip_frontmatter_for_github(content): |
| 623 | """去掉 Astro 专用 frontmatter 字段,只保留 title 和 pubDate。""" |
| 624 | lines = content.split('\n') |
| 625 | if not lines or lines[0].strip() != '---': |
| 626 | return content |
| 627 | |
| 628 | # 找到 frontmatter 结束位置 |
| 629 | end_idx = None |
| 630 | for i in range(1, len(lines)): |
| 631 | if lines[i].strip() == '---': |
| 632 | end_idx = i |
| 633 | break |
| 634 | if end_idx is None: |
| 635 | return content |
| 636 | |
| 637 | fm_lines = lines[1:end_idx] |
| 638 | body_lines = lines[end_idx + 1:] |
| 639 | |
| 640 | # 只保留 title 和 pubDate |
| 641 | keep_fields = {'title', 'pubDate'} |
| 642 | new_fm = [] |
| 643 | for line in fm_lines: |
| 644 | key = line.split(':')[0].strip() if ':' in line else '' |
| 645 | if key in keep_fields: |
| 646 | new_fm.append(line) |
| 647 | |
| 648 | result = ['---'] + new_fm + ['---', ''] + body_lines |
| 649 | return '\n'.join(result) |
| 650 | |
| 651 | |
| 652 | def disclose_full_issue(weekly_no): |
no outgoing calls
no test coverage detected