Skip to content

Unable to use page meta-data inside pages #161

@jaydson

Description

@jaydson

I just figure out users are unable to use pages meta-data inside in the pages context.
Example:
I want to list all pages I have in a template (imagine a menu).
This can be done easily in the index.html template, or even in partials (in the index context):

{% for page in pages %}
        <li class="meni__item">
            <a href="{{ page.href }}">{{ page.title | capitalize }}</a>
        </li>
{% endfor %}

Why this is possible?
Looking at Harmonic's code (src/bin/parser.js) in the function generateIndex:

const indexContent = indexTemplateNJ.render({
  posts,
  config,
  pages: pagesMetadata
});

As you can see, we're binding the pages meta-data.

But, unfortunately we can't use the same logic for pages, because this pages meta-data aren't being binding.
Look (src/bin/parser.js) in the function generatePages:

pageHTMLFile = pageTplNJ.render({
  page: _page,
  config: config
});

We just have the current page data, and not all pages.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions