remove redundant allPosts collection, rename misleading onlyMarkdown collection
This commit is contained in:
parent
04a6113258
commit
d406f25ff5
5 changed files with 6 additions and 12 deletions
|
|
@ -18,7 +18,7 @@ dotenv.config();
|
|||
import yaml from 'js-yaml';
|
||||
|
||||
// config import
|
||||
import {getAllPosts, onlyMarkdown, tagList} from './src/_config/collections.js';
|
||||
import {showInSitemap, tagList} from './src/_config/collections.js';
|
||||
import events from './src/_config/events.js';
|
||||
import filters from './src/_config/filters.js';
|
||||
import plugins from './src/_config/plugins.js';
|
||||
|
|
@ -35,8 +35,7 @@ export default async function (eleventyConfig) {
|
|||
eleventyConfig.addLayoutAlias('tags', 'tags.njk');
|
||||
|
||||
// --------------------- Collections
|
||||
eleventyConfig.addCollection('allPosts', getAllPosts);
|
||||
eleventyConfig.addCollection('onlyMarkdown', onlyMarkdown);
|
||||
eleventyConfig.addCollection('showInSitemap', showInSitemap);
|
||||
eleventyConfig.addCollection('tagList', tagList);
|
||||
|
||||
// --------------------- Plugins
|
||||
|
|
|
|||
|
|
@ -1,10 +1,5 @@
|
|||
/** All blog posts as a collection. */
|
||||
export const getAllPosts = collection => {
|
||||
return collection.getFilteredByGlob('./src/posts/**/*.md').reverse();
|
||||
};
|
||||
|
||||
/** All markdown files as a collection for sitemap.xml */
|
||||
export const onlyMarkdown = collection => {
|
||||
export const showInSitemap = collection => {
|
||||
return collection.getFilteredByGlob('./src/**/*.{md,njk}');
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ excludeFromSitemap: true
|
|||
---
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
{% for page in collections.onlyMarkdown %}
|
||||
{% for page in collections.showInSitemap %}
|
||||
{% if page.url and page.data.excludeFromSitemap != true %}
|
||||
|
||||
{% if page.data.lastUpdated %}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ layout: base
|
|||
title: Blog
|
||||
description: 'All blog posts can be found here'
|
||||
pagination:
|
||||
data: collections.allPosts
|
||||
data: collections.posts
|
||||
size: 8
|
||||
permalink: 'blog/{% if pagination.pageNumber >=1 %}page-{{ pagination.pageNumber + 1 }}/{% endif %}index.html'
|
||||
---
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ blog:
|
|||
<div class="feature | region region-space-l">
|
||||
<custom-masonry layout="50-50">
|
||||
<!-- loop posts -->
|
||||
{% set itemList = collections.allPosts %}
|
||||
{% set itemList = collections.posts %}
|
||||
{% asyncEach item in itemList.slice(0, 4) %}
|
||||
{% set definedDate = item.date %}
|
||||
{% include "partials/card-blog.njk" %}
|
||||
|
|
|
|||
Loading…
Reference in a new issue