ContentList
Markdown? Markdown is a useful format: It's easily edited by GUI editors, and popular in many different contexts for content management. It can also store meta data, such as date or product information like price or ISBN.
Use a ContentList definition to mix in a list of files for a sidebar or data collection. It's super powerful when combined with Markdown files, allowing for meta information and content. It supports use as both a site-map or list of links, a list type for managing CMS content, or as an easy way to collect many files of StaticData. When used as a site-map, it can provide a management command that builds all pages at once, for a complete SSG-style build.
Example 1: Simple list of pages
The most common usage is a single, global ContentList used as a "site map",
that has links to all your pages in it. This can also be the list used for
building -- just adding a build=build_all will register a new command.
See below for an example:
Note that by default ContentList is in CSV format (hence the comma
separated data), but that can be changed with -data-type=JSON etc.
Paths? - ContentList expects paths to be relative to the root path (e.g. project root). The root path is expected to be relative to the
static/directory, wherever that is set.Manually setting static - If ContentList can't find your files, try setting
modulo.rootPath = "../"(or something equivalent), to indicate the path from the currently viewed file to the root of your project.
Example 2: Loading Content
ContentList is also intended to collect the files it has listed. That is,
it will loop through and load all those files as content files, processing them
with the given content type (e.g. -load="json", -load="md"). Once collected,
it will expose them in a .files array, making it wasy to generate article
lists and other content-management tasks. See below:
Example 3: Maintaining a separate index list
Consider the case of including 30 survey data JSON files:
Clearly maintaining a long list like this is difficult. Thus, it's best to split it into a separate file. For example, the above can be rewritten into a separate file as such:
Then, using tools external to Modulo, we can maintain this
survey_file_list.csv file to make sure it has all the names of the files we
want to load. For example, using a shell such as bash or zsh, we can write:
By re-running this "find" command, the CSV file will be updated. By combining
the above with the entr command, this can be done automatically whenever
changes are detected. However, that is beyond the scope of this document.
Example 4: Article Markdown Powered CMS
Example 5: "E-Commerce" Markdown Powered CMS
It's also useful to use this for CMS files, for example for a E-Commerce store. See below for many simple Markdown files get loaded and formatted. Note that their extension are ommitted; however, they are Markdown-HTML files.