Flat

Transform Pushword in a FlatFile CMS.

Install

composer require pushword/flat-file

Configure (if needed)

Globally under pushword_static_generator (in config/packages).

Or for multi-sites in config/package/pushword.yaml.

...:
  flat_content_dir: content #default value

Usage

Sync with DB (import / export)

# Sync : automatically detects whether to import (files newer than DB) or export (DB newer or no files).
php bin/console pw:flat:sync [host]

# imports flat files into the database
php bin/console pw:flat:import [host]

# exports database content to flat files
php bin/console pw:flat:export [host] [exportDir] [--force]

Where:

  • host is facultative (uses default app if not provided)
  • exportDir (for export only) is facultative (uses flat_content_dir by default)
  • --force (for export only) forces overwriting even if files are newer than DB

Generate AI index

php bin/console pw:ai-index [host] [exportDir]

Generate two CSV files (pages.csv and medias.csv) with metadata useful for AI tools.

Where:

  • host is facultative (uses default app if not provided)
  • exportDir is facultative (uses flat_content_dir by default)

pages.csv

Contains page metadata with the following columns:

  • slug - Page slug
  • h1 - Page H1 title
  • createdAt - Creation date (Y-m-d H:i:s)
  • tags - Page tags
  • summary - Page summary/excerpt
  • mediaUsed - Comma-separated list of media files used in the page
  • parentPage - Parent page slug (if any)
  • pageLinked - Comma-separated list of page slugs linked in the content
  • length - Content length in characters

medias.csv

Contains media metadata with the following columns:

  • media - Media filename
  • mimeType - MIME type
  • name - Media name
  • usedInPages - Comma-separated list of page slugs using this media

Write

By default, the content may be organized in content/%main_host%/ dir and image may be in content/%main_host%/media or in media

Eg:

content
content/homepage.md
content/kitchen-skink.md
content/other-example-kitchen-sink.md
content/en/homepage.md
content/en/kitchen-skink.md
content/media/default/illustation.jpg
content/media/default/illustation.jpg.yaml

kitchen-sink.md may contain :


---

h1: 'Welcome in Kitchen Sink'
locale: fr
translations:
  - en/kitchen-skink
main_image: illustration.jpg
images:
  - illustration.jpg
parent:
  - homepage
metaRobots: 'no-index'
name: 'Kitchen Sink'
title: 'Kitchen Sink - best google restult'
#created_at: 'now' # see https://www.php.net/manual/fr/datetime.construct.php
#updated_at: 'now'

---

My Page content Yeah !

Good to know :

  • camel case or undescore case work
  • link to page must use slug
  • slug is generate from file path (removing .md) and can be override by a property in yaml front
  • homepage 's file could be named index.md or homepage.md
  • Other properties will be added to customProperties

illustation.jpg.yaml may contain

name: My Super Kitchen Sink Illustration