Skip to content

Commit

Permalink
Remove duplicate author information from blog posts (#587)
Browse files Browse the repository at this point in the history
  • Loading branch information
harishmohanraj authored Jan 21, 2025
1 parent 20c0128 commit f66890d
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
64 changes: 64 additions & 0 deletions test/website/test_process_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,64 @@ def test_dir(self):
tags: [Realtime API, Voice Agents, Swarm Teams, Twilio, AI Tools]
---
<div>
<img noZoom className="social-share-img"
src="https://media.githubusercontent.com/media/ag2ai/ag2/refs/heads/main/website/static/img/cover.png"
alt="social preview"
style={{ position: 'absolute', left: '-9999px' }}
/>
</div>
<div class="blog-authors">
<p class="authors">Authors:</p>
<CardGroup cols={2}>
<Card href="https://github.com/marklysze">
<div class="col card">
<div class="img-placeholder">
<img noZoom src="https://github.com/marklysze.png" />
</div>
<div>
<p class="name">Mark Sze</p>
<p>Software Engineer at AG2.ai</p>
</div>
</div>
</Card>
<Card href="https://github.com/sternakt">
<div class="col card">
<div class="img-placeholder">
<img noZoom src="https://github.com/sternakt.png" />
</div>
<div>
<p class="name">Tvrtko Sternak</p>
<p>Machine Learning Engineer at Airt</p>
</div>
</div>
</Card>
<Card href="https://github.com/davorrunje">
<div class="col card">
<div class="img-placeholder">
<img noZoom src="https://github.com/davorrunje.png" />
</div>
<div>
<p class="name">Davor Runje</p>
<p>CTO at Airt</p>
</div>
</div>
</Card>
<Card href="https://github.com/davorinrusevljan">
<div class="col card">
<div class="img-placeholder">
<img noZoom src="https://github.com/davorinrusevljan.png" />
</div>
<div>
<p class="name">Davorin</p>
<p>Developer</p>
</div>
</div>
</Card>
</CardGroup>
</div>
lorem ipsum""").lstrip()
(post2_dir / "index.mdx").write_text(post2_content)

Expand Down Expand Up @@ -332,6 +390,9 @@ def test_add_authors_and_social_img(self, test_dir):
assert '<p class="name">Chi Wang</p>' in actual
assert '<p class="name">Davor Runje</p>' not in actual

assert actual.count('<div class="blog-authors">') == 1
assert actual.count('<p class="name">Chi Wang</p>') == 1

# Verify content of second blog post
post2_path = generated_blog_dir / "2023-06-28-MathChat" / "index.mdx"
actual = post2_path.read_text()
Expand All @@ -343,6 +404,9 @@ def test_add_authors_and_social_img(self, test_dir):
assert '<p class="name">Davorin</p>' in actual
assert '<p class="name">Chi Wang</p>' not in actual

assert actual.count('<div class="blog-authors">') == 1
assert actual.count('<p class="name">Mark Sze</p>') == 1


class TestConvertCalloutBlocks:
@pytest.fixture
Expand Down
6 changes: 5 additions & 1 deletion website/process_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,11 @@ def add_authors_and_social_img_to_blog_posts(website_dir: Path) -> None:
</div>"""

# Generate authors HTML
authors_html = construct_authors_html(authors_list, all_authors_info)
authors_html = (
construct_authors_html(authors_list, all_authors_info)
if '<div class="blog-authors">' not in content
else ""
)

# Combine content
new_content = f"{front_matter_string}\n{social_img_html}\n{authors_html}\n{content}"
Expand Down

0 comments on commit f66890d

Please sign in to comment.