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

Add support for multiple tables of contents in the Solidus Guides #3093

Merged
merged 17 commits into from
Feb 15, 2019

Conversation

kennyadsl
Copy link
Member

@kennyadsl kennyadsl commented Feb 11, 2019

This PR is a reopening of the great @benjaminwil work on #2770:

Right now, the Solidus Guides include one guide: the Solidus Developers Guide.

In the future, we intend to publish other guides with separate tables of contents. For example, a guide for end users (which is partially written and available at /guides/source/users/) should be displayed separately from the Developers Guide, as the content is written for a non-developer audience.

These commits prepare the Solidus Guides to handle those additional TOCs.

This PR adds some commit to actually start displaying Users Guides in our guides website, making its link accessible via a new navigation in the header.

Mobile

schermata 2019-02-11 alle 14 16 07

Desktop
schermata 2019-02-11 alle 14 16 26

NOTE
I know it does not look perfect on a UI/UX point of view. We'll work on that later if others think this is an acceptable solution for now.

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)
  • I have added a CHANGELOG entry for this change (if needed)

As we gain multiple guides (e.g. Developers Guide, User Guide, API
Guide), the /index.html should be reserved as a landing page.

Instead of using /index.html while the Solidus Guides are only the
Solidus Developers Guide, let's redirect the homepage to
/developers/index.html.
@kennyadsl kennyadsl self-assigned this Feb 11, 2019
guides/source/partials/_nav_content.erb Outdated Show resolved Hide resolved
guides/lib/custom_markdown_renderer.rb Outdated Show resolved Hide resolved
guides/lib/custom_markdown_renderer.rb Show resolved Hide resolved
guides/helpers/nav_helpers.rb Outdated Show resolved Hide resolved
guides/config.rb Outdated Show resolved Hide resolved
@kennyadsl
Copy link
Member Author

@benjaminwil if you want to take a look it would be awesome, thanks!

benjaminwil and others added 10 commits February 11, 2019 15:58
This commit adds helper methods that will make rendering different
tables of contents on different parts of the site easy.

This also updates the discover_title helper to account for multiple
tables of contents.

\## Dealing with multiple tables of contents

For example, if I visit the following URL:

`localhost:4567/developers/orders/overview.html`

I should see the table of contents for the "Solidus Developers Guide".
And if I visit this URL:

`localhost:4567/users/promotions/overview.html`

I should see the table of contents for the "Solidus Users Guide".

Here's a description of the helpers's functionality:

\## table_of_contents

The table_of_contents helper allows you to determine which table of
contents should be rendered. If the user is viewing a URL with the
subdirectory `/developers/`, then the current table of contents will be
at the `/data/nav/developers.yml` YAML file.

\## current_guide

the current_guide helper finds which guide the user is viewing. If they
are a URL with the subdirectory `/developers/`, then the current guide
is the "Solidus Developers Guide".

The current_guide returns the YAML at `/data/nav/global.yml` which
allows you to get the `current_guide.title` and `current_guide.href` for
the current guide.
This commit enables multiple table of contents rendering for the Solidus
Guides.

Each table of contents can have as many "submenus" as you want. Here is
the YAML structure for a short submenu:

```
-
  - title: "Section name"
    dropdown:
      - title: "Article name"
        href: "/relative/link/to/article.html"
      - title: "Another article name"
        href: "/relative/link/to/another-article.html"
```

Things you should note about the structure:

- Each submenu is represented by a root `-` node that is unnamed.
- Each submenu can have multiple sections and multiple articles.
- Articles need to be included in a `dropdown:` at this point in time.

\## Global and Meta tables of contents

The `/data/nav/global.yml` and `/data/nav/meta.yml` do not follow this
data structure.  These are special menus that will be used throughout
the site and should not be rendered only when the user is on specific
pages.
Each table of contents provides a link to the `current_guide.href`. In
the case of the "Solidus Developers Guide" table of contents, that links
to `/developers/index.html`.

These links should be styled to look like the <h1> of the table of
contents block. This is similar to how the title of a blog is usually
the color of a heading or the site's logo, not the color of a link.
It allows to access page as users/page.html instead of users/page
like we do into other sections.
This was raising an error in the middleman console
by renaming product-stock.md into product-stock.html.md
@kennyadsl kennyadsl force-pushed the kennyadsl/guides/multiple_tocs branch from 1f225f8 to 038aea1 Compare February 11, 2019 14:59
This is needed to switch between Developers and Users guides. This
commit also changes the header structure a bit to accomodate this
new navigation.
It also please Rubocop by removing Ruby 2.3 syntax which makes
Hound to complain.
@kennyadsl kennyadsl force-pushed the kennyadsl/guides/multiple_tocs branch from 038aea1 to 97b676f Compare February 11, 2019 15:17
Copy link
Contributor

@benjaminwil benjaminwil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for continuing the work on this!

Copy link
Member

@spaghetticode spaghetticode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benjaminwil @kennyadsl thank you both for this great addition ❤️

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

I just noticed that we do not have a cursor: pointer on any link. I think this is bad UI. Nothing we need to tackle in this PR, but the links in the sidebar and in the content have color or font-weight changes that indicate a hover state, the .nav-link in the .guides-nav do not have any visual indicator on :hover. Maybe fix this at least?

@kennyadsl
Copy link
Member Author

Thanks for the review @tvdeyen, but I can't find links without cursor: pointer in both navigation and sidebar.

@tvdeyen
Copy link
Member

tvdeyen commented Feb 15, 2019

@kennyadsl Chrome I assume? In Firefox the links have no pointer. I guess they removed the default pointer for links and leave it to the site designers to use pointer cursors. Anyway, not important for this PR something we should think about later.

@kennyadsl
Copy link
Member Author

@tvdeyen yes, Chrome. I agree we can tackle this into a separate PR.

@kennyadsl kennyadsl merged commit 3aa74e7 into solidusio:master Feb 15, 2019
@kennyadsl kennyadsl deleted the kennyadsl/guides/multiple_tocs branch February 15, 2019 11:13
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

Successfully merging this pull request may close these issues.

None yet

6 participants