diff --git a/build.py b/build.py index e608a31..c7dc882 100644 --- a/build.py +++ b/build.py @@ -169,12 +169,13 @@ def main(): else: date_formatted = md_file.stem.replace('-', '.') + # ИСПРАВЛЕНО: добавлен / в начало ссылок card_html = f'''
-

{title}

+

{title}

{date_formatted}
{excerpt_html}
- Читать далее + Читать далее
''' news_cards.append(card_html) @@ -184,6 +185,27 @@ def main(): with open('public/news.html', 'w', encoding='utf-8') as f: f.write(TEMPLATE.format(title="Новости", content=news_content)) + + # добавлен код генерации отдельных страниц новостей + for md_file in news_files: + with open(md_file, 'r', encoding='utf-8') as f: + meta, body = parse_front_matter(f.read()) + + title = meta.get('title', md_file.stem.replace('-', ' ').title()) + breadcrumbs = build_breadcrumbs(f'/news/{md_file.stem}.html') + + back_link = f'← Назад к списку новостей' + full_content = breadcrumbs + back_link + '\n' + body + + html_content = markdown.markdown(full_content, extensions=['fenced_code', 'tables']) + + output_path = Path(f'public/news/{md_file.stem}.html') + output_path.parent.mkdir(parents=True, exist_ok=True) + + with open(output_path, 'w', encoding='utf-8') as f: + f.write(TEMPLATE.format(title=title, content=html_content)) + + print(f"✅ Создана страница новости: {output_path}") # 3. Страница сотрудников staff_by_lab = {}