changeset 292:c8a6c92b1867

docs: Pagination and assets' documentation.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 07 Mar 2015 22:53:35 -0800
parents 46842f71f31f
children d013cc191922
files docs/docs/03_content/06_pagination.md docs/docs/03_content/07_assets.md
diffstat 2 files changed, 106 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/docs/03_content/06_pagination.md	Sat Mar 07 22:53:35 2015 -0800
@@ -0,0 +1,70 @@
+---
+title: Pagination
+---
+
+There are typically a few pages that need to display a list of articles, like
+the main page of a blog. To do this in PieCrust, you can use the `pagination`
+variable on a page:
+
+    {% raw %}
+    {% for post in pagination.posts %}
+    ## [{{ post.title }}]({{ post.url }})
+    <span class="post-date">{{ post.date }}</span>
+    {{ post.content|safe }}
+    {% endfor %}
+    {% endraw %}
+
+This will display a list of posts, each with its title (note the level 2
+Markdown title syntax) as a link, its date, and its content.
+
+For more information on what's available on the `pagination` object, see the
+[templating data reference page][tpldata]. Also see the [templating
+documentation][tpl] for more general information about template engines in
+PieCrust.
+
+Note that the pagination variable is called like that because it will paginate
+the current page by creating sub-pages (see below). If you want to display pages
+with a list of posts without any pagination (i.e. without any sub-page), you can
+instead use the `blog.posts` template variable (see the documentation about the
+[default content model][dcm] for more information about that).
+
+
+## Pagination filtering
+
+If you want to create a page that lists only specific posts, you can filter what
+you get from the pagination object. You do this with the `posts_filters`
+configuration section in your page.
+
+For example:
+
+    posts_filters:
+      has_tags: announcement
+      has_tags: piecrust
+
+This will only return posts with both the `announcement` and `piecrust` tags.
+
+See the documentation on the [page filtering syntax][fil] for more information.
+
+
+## Sub-pages
+
+Most pages don’t have sub-pages — there’s just the page. However, pages that
+show a list of blog posts (or other lists involving pagination) could have
+sub-pages if there are too many blog posts.
+
+For example, if you only show 5 posts per page and you have written 17 posts in
+total, your blog’s main page would have 4 sub-pages: sub-page 1 would show posts
+17 to 13, sub-page 2 would show posts 12 to 7, etc. (posts are sorted in
+reverse-chronological order by default, but other things may be sorted
+differently).
+
+If a page’s URL is domain.com/blog, its 3rd sub-page’s URL would look like
+domain.com/blog/3. This means it’s a bad idea to create an actual page whose
+name is just a number!
+
+
+[tpl]: {{docurl('content/templating')}}
+[tpldata]: {{docurl('reference/templating-data')}}
+[dcm]: {{docurl('content-model/default-content-model')}}
+[fil]: {{docurl('content/filtering')}}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/docs/03_content/07_assets.md	Sat Mar 07 22:53:35 2015 -0800
@@ -0,0 +1,36 @@
+---
+title: Assets
+---
+
+Writing text is all good, but sometimes you need to add some pictures in your
+pages. You could easily handle this yourself by having an images folder at the
+root of your website with all your pictures in it:
+
+    ![my picture](/images/path/to/my/picture.png)
+
+However, your images folder could easily get cluttered and difficult to
+organize, especially if you use pictures a lot in your blog posts. And it's not
+super friendly to write.
+
+To solve some of these problems, PieCrust has a "_page assets_" mechanism for
+any kind of file you want to somehow be related to a page (pictures, audio
+files, etc.).
+
+You put all the assets for a page in a sub-directory that has the same name as
+the page file, with a `-assets` suffix. For instance, if you have a page at
+`pages/about/where-to-find-us.md`, you can create a
+`pages/about/where-to-find-us-assets` directory with stuff in it:
+
+    pages
+     |- about
+         |- where-to-find-us.html
+         |- where-to-find-us-assets
+             |- map.jpg
+             |- street-view.jpg
+
+Then, on the page, you can access those assets with the assets variable and the
+name of the asset (without the extension):
+
+    ![map to our place]({{ assets.map }})
+    ![our place]({{ assets['street-view'] }})
+