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

Allow provided collections to be overridden in a user’s configuration #361

Merged
merged 1 commit into from
Jan 2, 2025

Conversation

paulrobertlloyd
Copy link
Collaborator

@paulrobertlloyd paulrobertlloyd commented Dec 27, 2024

Fixes #360.

The plugin provides 4 built-in collections that are used by the provided layouts:

  • all (all files, but excluding SCSS files)
  • ordered (all Markdown and Nunjucks files, excluding tags, used for sub navigation)
  • sitemap (all Markdown files)
  • tags (all tags used by posts)

In most cases these shouldn’t need to be altered. However, should you want to update how these collections select pages (or tags), you can’t. This is because Eleventy doesn’t allow you to override collections that have already been configured.

This PR changes how these 4 collections are added so that any existing collection in the user’s Eleventy configuration that shares one of these names is used instead, and the plugin’s own collection will not be registered.

This PR also renames the ordered collection to navigation, making the intent of this collection clearer.

Once this PR is merged, it will be possible to address the use case outlined in #360 by adding a collection using Eleventy’s usual collection API methods.

@hickford
Copy link

Thanks for the fix. Could you give an example how to achieve #360?

@paulrobertlloyd paulrobertlloyd merged commit 46c8c6b into main Jan 2, 2025
2 checks passed
@paulrobertlloyd paulrobertlloyd deleted the overridable-collections branch January 2, 2025 16:00
@paulrobertlloyd
Copy link
Collaborator Author

paulrobertlloyd commented Jan 2, 2025

@hickford This feature is now in the latest release (v6.7.2). It depends which files you want to include in navigation, and which you don’t. Collections in 11ty can be created based on a tag or by using a glob of folder/file locations to include. If you can point me to your project repo, or give me an example of which pages you want in navigation and which you don’t, I can try to provide an example. 11ty’s documentation for managing collections may also be of help.

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

Successfully merging this pull request may close these issues.

How to exclude page from navigation but keep it in the sitemap?
3 participants