Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft tags show up in tag pagination even when excluding drafts #156

Open
adamwolf opened this issue Aug 3, 2023 · 1 comment
Open

Draft tags show up in tag pagination even when excluding drafts #156

adamwolf opened this issue Aug 3, 2023 · 1 comment

Comments

@adamwolf
Copy link

adamwolf commented Aug 3, 2023

When I add a tag to fifthpost.md with tags: hello, tags.njk generates a page for the hello tag at _site/tags/hello/index.html.

It doesn't show up in the loop in tags-list.njk, which is nice.

Is there a good way to not include draft tags in that pagination?

(I tried to dig into this a bit but I have to admit that although it works fine for me whenever I'm doing anything normal, I don't have my head around nitty gritty of how page data is processed.)

@adamwolf
Copy link
Author

I ended up working around this with something like the following:

---js
{
	pagination: {
		data: "collections",
		size: 1,
		addAllPagesToCollections: true,
		alias: "tag",
		filter: [
			"all",
		],
		before: function(paginationData, fullData) {
			// Filter out collections that don't have any items. (This fixes an issue where draft entry tags are included in production builds.)
			return paginationData.filter(entry => fullData.collections[entry].length > 0);
		},
	},
	permalink: "tags/{{ tag | slugify}}/",
	eleventyComputed: {
		title: data => `Tagged “${data.tag}”`,
	},
	layout: "layouts/blank.njk",
}
---

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant