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

config.addcollection(notes) already exist #9

Open
yazae opened this issue Aug 8, 2023 · 1 comment
Open

config.addcollection(notes) already exist #9

yazae opened this issue Aug 8, 2023 · 1 comment

Comments

@yazae
Copy link

yazae commented Aug 8, 2023

Hi, following my question in your theme project eleventy-garden, I tried your plugin and got an error :

[11ty] 1. Error processing the `BacklinksPlugin` plugin (via EleventyPluginError)
[11ty] 2. config.addCollection(notes) already exists. Try a different name for your collection. (via UserConfigError)

My steps

  1. I added your plugin in my .eleventy.js :
const eleventyBacklinks = require('eleventy-plugin-backlinks');

module.exports = function(eleventyConfig) {
	
  // plugin to add backlinks
  eleventyConfig.addPlugin(eleventyBacklinks, {
		folder: '/notes', // The folder with your notes
                getData: 'description'
    });
[]
}
  1. I installed the plugin with npm install eleventy-plugin-backlinks
  2. I commented notes.11tydata.js to avoid conflicts
  3. In the include backlinks.html, I tried to get the description passed through with getData ?
<hr>
<p class="larger" lang="en">
  Backlinks
</p>
{%- if backlinks.length > 0 -%}
<ul class="backlink">
  {%- for link in backlinks -%}
    <li class="backlink-note">
      <a href="{{- link.url -}}">
        <span class="larger">{{- link.title -}}</span>
          {{- link.preview | markdownify -}}
      </a>
    </li>
  {%- endfor -%}
</ul>
{%- else -%}
<p>
  Aucun <span lang="en">backlink</span> trouvé !
</p>
{%- endif -%}

And I got the collection error. Does your code is adding a collection note by itself then ?
How do we do to resolve this collection conflict ?

My .eleventy.js is indeed adding a collection, I don’t know if it’s your theme or the code I picked elswhere, but I’m pretty sure it’s needed elswhere in the code :

  eleventyConfig.addCollection("notes", function (collection) {
    return collection.getFilteredByGlob(["notes/*.md", "notes/Journal/*.md", "notes/Fakes/*.md"])
    .sort((a, b) => b.data.date - a.data.date);
  });

If I comment the collection code, I get another error linked to your plugin : 

[11ty] options.getData is not a function (via TypeError)

Do I have to declare a getData function by myself to get the note.description I just want to get ?

Again, sorry for being such a newbie, I don’t understand js very well when it’s at this scope u_u

Thanks in advance,

Yazae

@yazae
Copy link
Author

yazae commented Aug 8, 2023

Ok so I don’t need this plugin anymore since your theme works with the very simple modification I found at least, so you can close this issue if needed. I still feel that the documentation should be a bit clearer that the note collection is handled by your plugin, and how to modify the getData function, but yeah I’m a newbie.

Thanks for your works, plugins and theme, it helps a lot navigating in eleventy!

Yazae

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