Template: header
Template: markdown

Pod functions

The term "pod functions" is how we refer to the set of Amagaki's primary functions that are available to use throughout YAML, JavaScript, and template contexts. Pod functions allow you to interact with the objects in your website in a simple, predictable way.

Pod functions facilitate things like:

  • Listing and getting documents
  • Listing and getting collections
  • Listing and getting static files
  • Using pod metadata
  • Using pod locales

You will most frequently use pod functions via YAML type,s within YAML files, but when you are building plugins or templates, you may need to use the JavaScript API.

Examples

YAML

$view: /views/page.njk
# Create a menu containing three documents.
menu:
- doc: !pod.doc /content/pages/index.yaml
  title: Homepage
- doc: !pod.doc /content/pages/about.yaml
  title: About
- doc: !pod.doc /content/pages/contact.yaml
  title: Contact
{# Render the menu. #}
<ul>
    {% for item in doc.menu %}
        <li><a href="{{item.doc.url.path}}">{{item.title}}</a></li>
    {% endfor %}
</ul>

Learn about pod functions within YAML typesarrow_forward

JavaScript

// Get one document.
const doc = pod.doc('/content/pages/index.yaml');
 
// List all documents within the posts collection.
const docs = pod.docs('/content/posts/**');

See full API Referencelaunch

See API Reference for pod functionslaunch

Template: footer