Skip to content
New issue

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

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

Already on GitHub? # to your account

Add option eleventyExcludeFromCollections to virtual template and set to true as default #62

Open
lsolesen opened this issue Nov 25, 2024 · 2 comments

Comments

@lsolesen
Copy link

Right now the page created by the virtual template is added to the collections. Add the option to the virtual template options, so you can exclude the rss feed from the collections. Set to true, so it happens by default.

@querkmachine
Copy link

I expected to be able to set eleventyExcludeFromCollections using the templateData option, but it doesn't seem to have any effect, with the feed.xml file still appearing in the all collection.

eleventyConfig.addPlugin(feedPlugin, {
  type: "atom",
  outputPath: "/feed.xml",
  collection: {
    name: "blog",
    limit: 10,
  },
  metadata: {
    ...
  },
  templateData: {
    eleventyExcludeFromCollections: true,
  },
});

If it isn't possible to do this via templateData, then adding some setting for it would be useful.

I'm not sure if having it set by default would mesh with user expectations, though. Is there any existing precedent for an Eleventy page to be excluded from collections by default?

@zachleat
Copy link
Member

If collection.name is set, we do add eleventyExcludeFromCollections to the virtual template data cascade:

if(options.collection.name === "all") {
eleventyExcludeFromCollections = true;
eleventyImport = {};
} else {
eleventyExcludeFromCollections = [ options.collection.name ]
eleventyImport = {
collections: [ options.collection.name ],
};
}

I don’t think it would be necessary if the template isn’t consuming collections?

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants