bradfrost / pl-website-eleventy

MIT License
1 stars 1 forks source link

Order nav items #5

Open bradfrost opened 4 years ago

bradfrost commented 4 years ago

We need to set an order and have the ability to order nav items appropriately

QuincyGow commented 4 years ago

Ok. This provides an example of where I tend to get frustrated. There is no simple html list with the items. So I'm digging around trying to figure out where a list is, when, if it was an html, this would be simple. So I end up looking at every single type of file containing c-tree-nav or header nav just looking for a simple list of the items to no real avail.

QuincyGow commented 4 years ago

Add an order property to all the markdown files.

Space them out by 10. Order 10, order 20, etc...

Eleventy is a reference -custom ordering

QuincyGow commented 4 years ago

Update: I feel like I'm super close with this one.

-Step 1: I downloaded the plug-in via npm install @11ty/eleventy-navigation --save-dev

-Step 2: Added the following to eleventy.js under Import filters: const eleventyNavigationPlugin = require('@11ty/eleventy-navigation')

Added under Plugins: config.addPlugin(eleventyNavigationPlugin);

-Step 3: Then, in an attempt to follow the directions more closely, I added the following to a few of the files to try and get it to work:

---
title: Installing Pattern Lab
tags:
  - docs
category: getting-started
eleventyNavigation:
  key: Install
  parent: getting-started
order: 10
---

Still not working. May be that I'm getting the key and parent wrong? Not sure. Try again tomorrow.


Saturday status: Following the instructions on the eleventy site I added the eleventy nav plug-in npm install @11ty/eleventy-navigation --save-dev along with the js code:

const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
module.exports = function(eleventyConfig) {
  eleventyConfig.addPlugin(eleventyNavigationPlugin);
};

Then, for example, I added the property as so...

---
title: Upgrading Pattern Lab
tags:
  - demo-content
  - blog
  - media
category: getting-started
eleventyNavigation:
  order: 10
---

But it wouldn't work. Try again tomorrow.

QuincyGow commented 4 years ago

Dirty solution: Copying each .md and adding them in reverse order. The most recent add always goes to the top of the list. Of course, if you want to add something in the middle of the list you'd have to go through the whole list again, which would be a pain.

Continuing to try and get this to work.

QuincyGow commented 4 years ago

In order to test out different solutions I created a nav item navtest with two subnavs one and two trying basically to just switch them around.

I've followed the direction on the 11ty site to no avail.

There are a couple potential problems here.

bradfrost commented 4 years ago

@frostyweather I posted to the Eleventy project about ordering the nav items, and this is what people came back with: https://github.com/11ty/eleventy/issues/981

It seems like this navigation plugin would be the best to implement since it provides exactly this kind of functionality: https://github.com/11ty/eleventy-navigation

bradfrost commented 4 years ago

This logic is in here, all we need to do is add the order frontmatter to each doc file.