diff --git a/build.py b/build.py
index fe861ea..c012544 100644
--- a/build.py
+++ b/build.py
@@ -136,17 +136,52 @@ def main():
if Path('content/index.md').exists():
build_page(Path('content/index.md'), 'public/index.html', 'Главная')
- # 2. Страница новостей
+ # 2. Страница новостей (с карточками)
news_files = sorted(Path('content/news').glob('*.md'), reverse=True)
- news_links = "".join([f'
{f.stem.replace("-", " ").title()}' for f in news_files])
- # Добавляем хлебные крошки к контенту
+
+ news_cards = []
+ 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())
+ date = meta.get('date', '')
+
+ # Берем первые 200 символов как анонс
+ excerpt = body[:200].strip()
+ if len(body) > 200:
+ excerpt += '...'
+
+ # Конвертируем в HTML (только первый абзац)
+ first_paragraph = body.split('\n\n')[0] if '\n\n' in body else body[:150]
+ excerpt_html = markdown.markdown(first_paragraph, extensions=['fenced_code'])
+
+ # Форматируем дату
+ if date:
+ try:
+ from datetime import datetime
+ date_obj = datetime.strptime(date, '%Y-%m-%d')
+ date_formatted = date_obj.strftime('%d.%m.%Y')
+ except:
+ date_formatted = date
+ else:
+ date_formatted = md_file.stem.replace('-', '.')
+
+ card_html = f'''
+ '''
+
+ news_cards.append(card_html)
+
breadcrumbs = build_breadcrumbs('/news.html')
- news_content = breadcrumbs + "Последние новости
"
+ news_content = breadcrumbs + "Последние новости
" + "".join(news_cards)
with open('public/news.html', 'w', encoding='utf-8') as f:
- f.write(TEMPLATE.format(title="Новости", content=f"Последние новости
"))
- for md_file in news_files:
- build_page(md_file, Path(f'public/news/{md_file.stem}.html'), md_file.stem.replace('-', ' ').title())
+ f.write(TEMPLATE.format(title="Новости", content=news_content))
# 3. Страница сотрудников
staff_by_lab = {}