This repository has been archived by the owner on Nov 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from contentful-labs/feature/23-add-meta-data
feat: Add file meta documentation
- Loading branch information
Showing
3 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# File meta | ||
|
||
Contentful-metalsmith enriches the data available in templating with useful metadata. | ||
|
||
## `_fileName` | ||
|
||
**Which files:** all | ||
|
||
Every by contentful-metalsmith rendered file includes this meta information. | ||
This can be convenient when linking to child pages. | ||
|
||
```html | ||
<!doctype html> | ||
<html lang="en"> | ||
<head></head> | ||
<body> | ||
<ul> | ||
<!-- available data fetched from contentful --> | ||
{{#each data.entries }} | ||
<li> | ||
<h2>{{fields.title}}</h2> | ||
<p>{{fields.description}}</p> | ||
<!-- convenience property _fileName for easy linking --> | ||
<p><a href="{{_fileName}}">Read more</a></p> | ||
</li> | ||
{{/each}} | ||
</ul> | ||
{{contents}} | ||
</body> | ||
</html> | ||
``` | ||
|
||
## _parentFileName | ||
|
||
**Which files:** entry pages of a collection | ||
|
||
When rendering a collection page for a given content type and also rendering every entry of this content type the child page for each entry will include this parent file information. | ||
For further information check the [entry_template option](https://github.com/contentful-labs/contentful-metalsmith/blob/master/docs/source-file-settings.md#entry_template-optional). | ||
|
||
```html | ||
<!doctype html> | ||
<html lang="en"> | ||
<head></head> | ||
<body> | ||
<main class="l-container"> | ||
<a href="/{{ _parentFileName }}">Go back</a> | ||
</main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters