Creating 11ty Dynamic Categories plugin (with 2-level pagination)

Поделиться
HTML-код
  • Опубликовано: 12 сен 2024

Комментарии • 16

  • @maxray69
    @maxray69 Год назад +1

    This is exactly what I’ve been trying to sort! 👏🏻

    • @bryanlrobinson
      @bryanlrobinson  Год назад

      It was definitely a common question! Hope it helps!

  • @arig8964
    @arig8964 Год назад

    thank you very very very much! i'll try it out now!

  • @qrayg
    @qrayg Год назад

    For the life of me, I cannot get this to fully work.
    It does generate the folder structure for my categories, but the posts array is always empty no matter what I do.
    I can't wait for this to get more developed though... I truly am looking forward to using it.

    • @bryanlrobinson
      @bryanlrobinson  Год назад

      Feel free to link to a GitHub repository and I'll take a look. It's super alpha but SHOULD still be showing your posts. Happy to debug the implementation some

    • @Lucas-qr7ul
      @Lucas-qr7ul Год назад

      @@bryanlrobinson I got the same issue. Did you end up figuring it out?

  • @arig8964
    @arig8964 Год назад

    It works and rocks, so thanks again. I just couldn't get how to display the first and the last pages in the pagination list. I can see next and previous items fine.

    • @bryanlrobinson
      @bryanlrobinson  Год назад

      Do you mean the page numbers for the first and last pages don't show up or that there's no "First" and "Last" link in the pagination? Right now pagination isn't set up to do "first/last", but could be updated to provide that as an option, potentially.

    • @arig8964
      @arig8964 Год назад

      @@bryanlrobinson yes, i meant the page numbers for the first and last pages. i look forward to them to appear. thanks!

    • @bryanlrobinson
      @bryanlrobinson  Год назад

      @@arig8964 The numbers themselves should appear. Do you have a repository where you're using the plugin? I'm happy to take a look and see why they're not showing up

  • @李莯瑶
    @李莯瑶 11 месяцев назад

    Hi Bryan, thanks for developing such good tools. I just want to know if i have two collections, one is post another is project. what should i do ? Thanks.

    • @bryanlrobinson
      @bryanlrobinson  11 месяцев назад

      The regular pattern for this in 11ty is to use `addPlugin` again with the new collection string. So for each Collection you want to make a new addPlugin in your config file.

    • @李莯瑶
      @李莯瑶 11 месяцев назад

      ​@@bryanlrobinsonHi Bryan, thank you for taking the time to respond. I've added another new collection string just like this:
      ```javascript
      // eleventy-plugin-dynamic-categories
      eleventyConfig.addPlugin(dynamicCategories, {
      categoryVar: "categories",
      itemsCollection: "post",
      categoryCollection: "categories",
      perPageCount: 5,
      });
      eleventyConfig.addPlugin(dynamicCategories, {
      categoryVar: "categories",
      itemsCollection: "project",
      categoryCollection: "projectcategories",
      perPageCount: 5,
      });
      ```
      I followed the steps as you explained in the video. However, the first collection works well, but the second collection is not working on my project page.
      Here is my GitHub repo; if you don't mind taking a look, I would greatly appreciate it: [GitHub Repo]github.com/NING3739/11tybuildsite.

  • @MatildeRosero
    @MatildeRosero Год назад

    Hi, first of all, thank you so much for making this! I'm fairly new at Eleventy and was having trouble understanding discussions of how to do this (my use case is stories, and I want to use it for multichapter stories eventually).
    I followed along with your video and everything works great except for one details: not all of my categories are not single words, I might use for instance something like "modern setting. What happens in this case is that the links that the plugin generates (both in the list of categories on index and in the pagination) have slugified the category names, but the directory structure that is generated doesn't slugify the categories, so the actual directory will be like /posts/modern setting/index.html
    I am guessing the reason is the part in the plugin that is using tagName for both slug and title (saw it in the but that generates the tagMap)?

    • @MatildeRosero
      @MatildeRosero Год назад +1

      That was indeed the issue. On .eleventy-config in the github repo, on line 60, I added :
      let tagSlug = slugify(tagName);
      Then on line 69 (previously 68), I changed it to:
      permalinkScheme: `${tagSlug}${currentNumber > 1 ? `/${currentNumber}` : ''}/index.html`,
      Works perfect with categories with names of more than one word now!

    • @avinashmurmu9070
      @avinashmurmu9070 Год назад

      @@MatildeRosero even tagSlug should be slugify(tagSlug)