How to use the mkdocs.mkdocs.NavItem function in mkdocs

To help you get started, we’ve selected a few mkdocs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mkdocs / mkdocs / mkdocs / mkdocs.py View on Github external
def build_nav(config):
    # TODO: Allow more than two levels of nav.
    ret = []
    for path, title in config['index']:
        url = path_to_url(path, config)
        title, sep, child_title = title.partition('/')
        title = title.strip()
        child_title = child_title.strip()
        if not child_title:
            # New top level nav item
            nav = NavItem(title=title, url=url, children=[])
            ret.append(nav)
        elif not ret or (ret[-1].title != title):
            # New second level nav item
            child = NavItem(title=child_title, url=url, children=[])
            nav = NavItem(title=title, url=None, children=[child])
            ret.append(nav)
        else:
            # Additional second level nav item
            child = NavItem(title=child_title, url=url, children=[])
            ret[-1].children.append(child)
    return ret
github mkdocs / mkdocs / mkdocs / mkdocs.py View on Github external
def build_nav(config):
    # TODO: Allow more than two levels of nav.
    ret = []
    for path, title in config['index']:
        url = path_to_url(path, config)
        title, sep, child_title = title.partition('/')
        title = title.strip()
        child_title = child_title.strip()
        if not child_title:
            # New top level nav item
            nav = NavItem(title=title, url=url, children=[])
            ret.append(nav)
        elif not ret or (ret[-1].title != title):
            # New second level nav item
            child = NavItem(title=child_title, url=url, children=[])
            nav = NavItem(title=title, url=None, children=[child])
            ret.append(nav)
        else:
            # Additional second level nav item
            child = NavItem(title=child_title, url=url, children=[])
            ret[-1].children.append(child)
    return ret
github mkdocs / mkdocs / mkdocs / mkdocs.py View on Github external
def build_nav(config):
    # TODO: Allow more than two levels of nav.
    ret = []
    for path, title in config['index']:
        url = path_to_url(path, config)
        title, sep, child_title = title.partition('/')
        title = title.strip()
        child_title = child_title.strip()
        if not child_title:
            # New top level nav item
            nav = NavItem(title=title, url=url, children=[])
            ret.append(nav)
        elif not ret or (ret[-1].title != title):
            # New second level nav item
            child = NavItem(title=child_title, url=url, children=[])
            nav = NavItem(title=title, url=None, children=[child])
            ret.append(nav)
        else:
            # Additional second level nav item
            child = NavItem(title=child_title, url=url, children=[])
            ret[-1].children.append(child)
    return ret
github mkdocs / mkdocs / mkdocs / mkdocs.py View on Github external
url = path_to_url(path, config)
        title, sep, child_title = title.partition('/')
        title = title.strip()
        child_title = child_title.strip()
        if not child_title:
            # New top level nav item
            nav = NavItem(title=title, url=url, children=[])
            ret.append(nav)
        elif not ret or (ret[-1].title != title):
            # New second level nav item
            child = NavItem(title=child_title, url=url, children=[])
            nav = NavItem(title=title, url=None, children=[child])
            ret.append(nav)
        else:
            # Additional second level nav item
            child = NavItem(title=child_title, url=url, children=[])
            ret[-1].children.append(child)
    return ret