# Content pages

The Content module owns the `pages` table (title, slug and body translatable, `legal_key`, `is_published`,
`in_footer`, `position`) and `page_slug_history` (former slugs per language, written by the model's `updating` hook).

- `Content\Contracts\Pages` is what the storefront uses: `find($slug, $locale, $fill)` returns a `PageView` (published
  only; a former or Romanian slug finds it too, and the controller answers 301 to the current address), `footer()` the
  footer links, `sitemap()` the slugs for `pages-<locale>-1.xml`.
- The body is Markdown, rendered with `Str::markdown` with `html_input: escape` and unsafe links dropped. `{key}`
  placeholders are replaced before rendering with the values the storefront passes (`Storefront\Http\Controllers\PageController::fill()`
  builds them from `Platform\Contracts\ShopCompany` and the store context).
- `Content\Pages\LegalPages` lists the legal pages and installs the missing ones as drafts from
  `packages/core/resources/legal/ro/<key>.md`. Legal pages are Romanian; edit the templates there.
- Admin: `admin.content.pages.*`, permission `content.manage`.

## Landing pages

- `landing_pages` (`Models\LandingPage`: translatable `title`, `slug`, `seo_description`; `layout` jsonb;
  `is_published`, `starts_at`, `ends_at`; media collection `images` on the `media` disk with `card` and `wide` WebP
  conversions) and `landing_slug_history` (former slugs, written in the model's `updating` hook).
- `Landing\Layout::normalise(input, locales)` is the whitelist every layout goes through, on save and on render: rows
  (`width` contained | wide, `tone` plain | muted, up to 30), columns (`span` 12 | 8 | 6 | 4 | 3, at most twelve twelfths
  a row), modules (up to 6 a column): `text` (Markdown per language), `products` (`source` skus | category | brand |
  promotion, `limit` 1–24), `banner` (`media_id`, texts, `link` only a shop path or `https://`), `brands`
  (`brand_ids`). Unknown types and fields are dropped, texts cut.
- `Contracts\Landings` (`Landing\DatabaseLandings`): `find(slug, locale)` (any state; `LandingView::$live`, `$ended`)
  renders text with `Str::markdown` (`html_input: escape`, no unsafe links) and resolves banner images; `sitemap()` the
  live pages' slugs (added to `pages-<locale>-1.xml` by `Storefront\Seo\Sitemaps`).
- Storefront: `Storefront\Http\Controllers\LandingController` (`store.{locale}.landing`, `/campanie/{slug}`): a page
  not live opens only with a valid signature (the admin's `URL::temporarySignedRoute`, an hour, noindex); an ended one
  answers 410; a former slug 301. Products come from `VariantDirectory::productsBySku()` + `CatalogBrowser::cards()`
  (in the written order), `CatalogBrowser::products()` for a category or brand, and `Promotions\Contracts\Offers::covers()`
  for a promotion (its products, else its first category, else its brands, else the catalog), priced by `Shelf`.
- Admin: `Http\Controllers\LandingPageController` (`admin.content.landings.*`, `content.manage`), the builder is the
  Alpine component `landingBuilder` (`packages/core/resources/js/admin/landing-builder.js`) posting the layout as one JSON field.

## Blog

- `blog_categories` (`Models\BlogCategory`: translatable `name`, `slug`, `description`; `position`), `articles`
  (`Models\Article`: translatable `title`, `slug`, `excerpt`, `body` (Markdown), `seo_description`; `faq` jsonb list of
  `{question: {locale: text}, answer: {locale: text}}`; `author`; `is_published`, `published_at`; media collection
  `cover` (single file, `card` 800×450 crop and `wide` 1600×900 WebP)), `article_product` (`position`), and
  `blog_slug_history` (`kind` article | category; written by the `KeepsBlogSlugs` trait's `updating` hook).
- Live = published with `published_at` past. Saving published without a date sets it to now, once.
- `Contracts\Articles` (`Blog\DatabaseArticles`): `page()` (paginator of `ArticleCard`), `latest()`, `forProduct()`,
  `find()` (any state, `ArticleView::$live`; Markdown with `html_input: escape`; questions kept only with both texts),
  `category()`, `categories()` (those with live articles), `any()`, `sitemap()`.
- Storefront: `Storefront\Http\Controllers\BlogController`: `store.{locale}.blog` (`/blog`, `?page=`),
  `store.{locale}.blog.category` (`/blog/categorie/{slug}`), `store.{locale}.article` (`/blog/{slug}`; not live only with
  a valid signature, noindex). JSON-LD: `StructuredData::article()` (`BlogPosting`, author a `Person` when named, else
  the shop's `Organization`) and `StructuredData::faq()` (`FAQPage`, only from the questions on the page). The product
  page lists `Articles::forProduct()`; the footer links the blog when `Articles::any()`; `Sitemaps` adds the blog,
  categories and articles to `pages-<locale>-1.xml`.
- Landing pages: the `articles` module (`title`, `category_id`, `limit` 1–12) renders `Articles::latest()`.
- Admin: `ArticleController` (`admin.content.articles.*`, tabs, cover upload) and `BlogCategoryController`
  (`admin.content.articles.categories.*`), `content.manage`.

Tests: `tests/Feature/Content/PagesTest.php`, `tests/Feature/Content/LandingPagesTest.php`,
`tests/Feature/Content/BlogTest.php`.
