Обновить build.py
This commit is contained in:
parent
15625d859b
commit
3e10b7255a
26
build.py
26
build.py
@ -169,12 +169,13 @@ def main():
|
|||||||
else:
|
else:
|
||||||
date_formatted = md_file.stem.replace('-', '.')
|
date_formatted = md_file.stem.replace('-', '.')
|
||||||
|
|
||||||
|
# ИСПРАВЛЕНО: добавлен / в начало ссылок
|
||||||
card_html = f'''
|
card_html = f'''
|
||||||
<div class="news-card">
|
<div class="news-card">
|
||||||
<h2><a href="news/{md_file.stem}.html">{title}</a></h2>
|
<h2><a href="/news/{md_file.stem}.html">{title}</a></h2>
|
||||||
<div class="news-date">{date_formatted}</div>
|
<div class="news-date">{date_formatted}</div>
|
||||||
<div class="news-excerpt">{excerpt_html}</div>
|
<div class="news-excerpt">{excerpt_html}</div>
|
||||||
<a href="news/{md_file.stem}.html" class="news-read-more">Читать далее</a>
|
<a href="/news/{md_file.stem}.html" class="news-read-more">Читать далее</a>
|
||||||
</div>'''
|
</div>'''
|
||||||
|
|
||||||
news_cards.append(card_html)
|
news_cards.append(card_html)
|
||||||
@ -184,6 +185,27 @@ def main():
|
|||||||
|
|
||||||
with open('public/news.html', 'w', encoding='utf-8') as f:
|
with open('public/news.html', 'w', encoding='utf-8') as f:
|
||||||
f.write(TEMPLATE.format(title="Новости", content=news_content))
|
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'<a href="/news.html" class="back-link">← Назад к списку новостей</a>'
|
||||||
|
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. Страница сотрудников
|
# 3. Страница сотрудников
|
||||||
staff_by_lab = {}
|
staff_by_lab = {}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user