New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data sources #46

Closed
yosymfony opened this Issue Aug 4, 2015 · 0 comments

Comments

Projects
None yet
1 participant
@yosymfony
Copy link
Member

yosymfony commented Aug 4, 2015

Data sources can load data from certain locations like filesystem or database. Every data source must extends AbstractDataSource. Data loaded from data sources are called items. There is three type of them: content, layout and include. Items must implements ItemInterface.

Type of items:

  • content: regular content like post or pages.
  • layout: indicates how to organize the content.
  • include: reusable content.

FilesystemDataSource

Spress comes with FilesystemDataSource for loading your site (see #41 ). Data sources are defined at data_source option of the configuration file:

data_sources:
  filesystem:
    class: 'Yosymfony\Spress\Core\DataSource\Filesystem\FilesystemDataSource'
    arguments:
      source_root: '%site_dir%/src'
      include: '%include%'
      exclude: '%exclude%'
      text_extensions: '%text_extensions%'
      attribute_syntax: '%attribute_syntax%'

This is the default configuration and is not necessary to modify your config.yml file at your site.

Adds a custom data source from a plugin

Extends Spress with a new data source is straightforward:

  • Suscribes to spress.start event and gets the EnvironmentEvent object received as an argument.
  • Adds a custom data source:
$dsm = $environmentEvent->getDataSourceManager();
$dsm->addDataSource('dataSource-name', $yourDataSource);

Adds a custom data source from the config.yml file

You can also adds your own data source using config.yml file of your site:

data_sources:
  myCustomDataSource:
    class: 'Class\of\myCustomDataSource'
    arguments:
      argument1: "your value"

Note: if you want hold the filesystem data source don't forget appear that.

@yosymfony yosymfony added this to the Spress 2.0.0 alpha1 milestone Aug 4, 2015

@yosymfony yosymfony closed this Sep 15, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment