p = 'frontend/src/components/ArticleLink.jsx'
s = open(p).read()
s = s.replace("export default function ArticleLink({ slug, sectionId = null, children, className = '' }) {",
"""export default function ArticleLink({ slug, sectionId = null, sectionTitle = null,
                                     children, className = '' }) {""")
s = s.replace('''          <span className="al-card-title">{preview.title}</span>
          {preview.excerpt && <span className="al-card-excerpt">{preview.excerpt}</span>}''',
'''          <span className="al-card-title">{preview.title}</span>
          {/* Which part of it, when the link lands on one. The article names
              the subject and the section says where in it — a card headed
              only "Treatment" is a heading with no subject. */}
          {sectionTitle && <span className="al-card-section">in {sectionTitle}</span>}
          {preview.excerpt && <span className="al-card-excerpt">{preview.excerpt}</span>}''')
open(p, 'w').write(s)

q = 'frontend/src/components/QuestionReadingLinks.jsx'
t = open(q).read()
t = t.replace('''            slug={String(link.article_id)} sectionId={link.section_id || null}
            className="question-reading-chip">''',
'''            slug={String(link.article_id)} sectionId={link.section_id || null}
            sectionTitle={link.section_title || null}
            className="question-reading-chip">''')
open(q, 'w').write(t)
print('done')
