"""Small independent site shared by theme/layout integration and browser acceptance."""
from pathlib import Path
from site_engine.parsing import frontmatter
from site_engine.parsing.yamlio import dump_yaml
def write(root: Path, rel: str, text: str):
path = root / rel
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(text, encoding="utf-8")
def document(preset="minimal", overrides=None):
return {"schema": 1, "preset": preset, "preset_version": 1, "overrides": overrides or {}}
def seed(root: Path):
write(root, "site.yaml", dump_yaml({
"schema": 1, "name": "Width and theme checks", "theme": {"file": "theme.yaml"},
"base_url": "https://theme.example", "defaults": {"layout": "default"},
}))
write(root, "theme.yaml", dump_yaml(document(overrides={"ui": {"container": {
"mode": "boxed", "max_width": 1080, "gutter": {"desktop": 36, "tablet": 24, "mobile": 16},
}}})))
write(root, "layouts/default/layout.yaml", dump_yaml({
"id": "default", "regions": [
{"id": "header", "fixed": [{"id": "header_fixed", "fragment": "site_header"}]},
{"id": "main", "allow": ["*"]},
{"id": "footer", "fixed": [{"id": "footer_fixed", "fragment": "site_footer"}]},
],
}))
write(root, "layouts/default/layout.html.j2", """
{{ seo_head() }}{{ assets_head() }}{{ region('header') }}{{ region('main') }}{{ region('footer') }}{{ assets_body() }}""")
write(root, "assets/check.css", ".f-site_header{position:sticky;top:0;z-index:10;background:var(--color-surface)} .f-richtext p{overflow-wrap:anywhere}")
write(root, "pages/index.md", frontmatter.dumps({
"schema": 1, "title": "Проверка ширины секций", "status": "published",
"regions": {"main": [
{"id": "hero_home", "fragment": "hero", "props": {"title": "Файловая тема и ширина секций", "subtitle": "Общий контракт сборки и preview", "actions": [{"url": "https://example.org", "label": "Основная кнопка"}]},
"layout": {"section_width": "full", "content_width": "boxed"}},
{"id": "section_outer", "fragment": "section", "props": {"title": "Родительская секция", "text": "Ширина фона и содержимого настраиваются отдельно."},
"layout": {"section_width": "fluid", "content_width": "full"}, "slots": {"content": [
{"id": "richtext_child", "fragment": "richtext", "props": {"content": "## Вложенный блок\n\nСобственная ширина вложенного блока."},
"layout": {"section_width": "boxed", "content_width": "fluid"}},
]}},
{"id": "columns_grid", "fragment": "columns", "props": {"count": "2"}, "slots": {"col_1": [
{"id": "richtext_column", "fragment": "richtext", "props": {"content": "Содержимое первой колонки"}},
]}},
*[{"id": f"richtext_long_{i}", "fragment": "richtext", "props": {"content": "## Текстовая секция\n\n" + ("Проверка прокрутки. " * 60)}} for i in range(8)],
]},
}))
write(root, "collections/articles.yaml", dump_yaml({
"id": "articles", "name": "Статьи", "route": "/articles/{slug}/", "body": "markdown",
"fields": [{"key": "title", "type": "text", "required": True}],
}))
write(root, "display/articles.yaml", dump_yaml({
"layout": "default", "regions": {"main": [
{"id": "display_text", "fragment": "richtext", "layout": {"section_width": "full", "content_width": "boxed"}, "props": {"content": {"bind": "entry.body"}}},
]},
}))
write(root, "content/articles/first.md", frontmatter.dumps({
"title": "Первая статья", "status": "published", "regions": {"main": [
{"id": "entry_text", "fragment": "richtext", "layout": {"section_width": "fluid", "content_width": "full"}, "props": {"content": "Текст записи"}},
]},
}, "Текст из Display."))