mitodl / ocw-to-hugo

A command line utility for taking master.json output from ocw-data-parser and producing markdown for use with hugo-course-publisher
3 stars 0 forks source link

Regression: pages with list_in_left_nav=False are showing up in left nav #281

Open pdpinch opened 3 years ago

pdpinch commented 3 years ago

As a course author, I want to hide some pages from the left navigation, but still have them available in the course.

For example, compare the left nav on legacy OCW 11.405 SP21

image

with OCW Next 11.405 SP21

image

This choice is indicated in the parsed JSON by the list_in_left_nav key. When it is present and set to false, the item should appear in the left nav.

For example the JSON at s3://open-learning-course-data-production/11-405-just-money-banking-as-if-society-mattered-spring-2021 contains:

    {
      "list_in_left_nav": false, 
      "file_location": "42302a80a779eca6385816bd7c7a6bf1_syllabus.html", 
      "type": "CourseSection", 
      "uid": "42302a80a779eca6385816bd7c7a6bf1", 
      "title": "Syllabus", 
      "url": "/courses/urban-studies-and-planning/11-405-just-money-banking-as-if-society-mattered-spring-2021/syllabus", 
      "text": "", 
      "is_image_gallery": false, 
      "order_index": null, 
      "bottomtext": "", 
      "short_page_title": "Syllabus", 
      "short_url": "syllabus", 
      "parent_uid": "582eb8f5f39dfebe0aef874da6a2623e", 
      "is_media_gallery": false, 
      "description": ""
    }

related issue:

noisecapella commented 3 years ago

@pdpinch What is the expected behavior here? I'm not familiar with what list_in_left_nav does

pdpinch commented 3 years ago

Sorry George, the history of issues and PRs on this are not clear. I updated the description and I hope it makes sense now.

gumaerc commented 3 years ago

@pdpinch FYI the reason for the link in your example showing up when list_in_left_nav is set to false is because of this:

  if (inRootNav || listInLeftNav) {
    courseSectionFrontMatter["menu"] = {
      leftnav: {
        identifier: pageId,
        name:       shortTitle || "",
        weight:     menuIndex
      }
    }
    if (parentId) {
      courseSectionFrontMatter["menu"]["leftnav"]["parent"] = parentId
    }
  }

Since Syllabus is in the root of the nav, it's shown regardless. It looks like I had come to that conclusion here: https://github.com/mitodl/hugo-course-publisher/issues/181. It seems at that point, list_in_left_nav was not being set at all for root level items so it was assumed that they were to be shown regardless.

noisecapella commented 3 years ago

Yes, as Carey said list_in_left_nav has the correct values for 11-405-just-money-banking-as-if-society-mattered-spring-2021 but it doesn't have the correct values for 20-020-introduction-to-biological-engineering-design-spring-2009 which is the course linked in https://github.com/mitodl/hugo-course-publisher/issues/181, so I don't think we can use it for the sidebar

noisecapella commented 3 years ago

@pdpinch For example, the Syllabus page for 20-020 is listed in the sidebar: Screenshot from 2021-06-23 09-34-55

But it is false in the parsed JSON: Screenshot from 2021-06-23 09-35-39

pdpinch commented 3 years ago

Here's another example where

"list_in_left_nav": false,

but the item still appears in the left nav.

OCW Next: https://ocwnext.odl.mit.edu/courses/6-036-introduction-to-machine-learning-fall-2020/ Legacy: https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-036-introduction-to-machine-learning-fall-2020/

pdpinch commented 3 years ago

After investigating this further, it looks like we maybe should be using a different key from the raw Plone JSON, excludeFromNav, instead of list_in_left_nav