cinder icon indicating copy to clipboard operation
cinder copied to clipboard

Is index.md supported?

Open andre2007 opened this issue 6 years ago • 8 comments

Is the index.md feature supported as described here?

https://github.com/mkdocs/mkdocs/issues/1139#issuecomment-449770285

andre2007 avatar Oct 20 '19 08:10 andre2007

Not that I am aware of. It looks like Waylan described how to implement it in this SO thread: https://stackoverflow.com/questions/54596774/how-to-add-permalinks-to-tree-nodes-in-markdown-nav-file-mkdocs-yml/54598748#54598748

Please let us know if you come up with an approach!

chrissimpkins avatar Oct 20 '19 13:10 chrissimpkins

My understanding is, there was a decision for a convention based approach to be implemented by the themes.

An index.md as first array element should be used as target, but not rendered as normal entry.

Why did you close the issue?

andre2007 avatar Oct 20 '19 15:10 andre2007

Apologies. I interpreted this as a question about whether we support this as your title suggests.

chrissimpkins avatar Oct 20 '19 16:10 chrissimpkins

I don't closely follow the upstream project. If you are aware of conventions that are in place I would be happy to have a look and see how we can bring this into compliance with guidance.

chrissimpkins avatar Oct 20 '19 16:10 chrissimpkins

This is a comment from @waylan I am referring to:

In the end, we settled on sorting pages so that an auto-generated nav would list an index file (index.md) as the first item within a parent with the expectation that themes could detect that and do something special with it (use it as the "folder level page"). In other words, MkDocs provides the mechanism for it to be possible as long as themes provide support to display it correctly. However, I'm not aware of any themes which have implemented support for it yet.

Source https://github.com/mkdocs/mkdocs/issues/1139#issuecomment-449097071

andre2007 avatar Oct 20 '19 17:10 andre2007

For future reference, here is an implementation suggestion from Waylan:

{% if nav|length>1 %}
    <ul>
    {% for nav_item in nav %}
        {% if nav_item.children %}
            <li>{% if nav_item.children[0].is_index %}
                    <a href="{{ nav_item.children[0].url|url }}">{{ nav_item.title }}</a>
                {% else %}
                    {{ nav_item.title }}
                {% endif %}
                <ul>
                {% for nav_item in nav_item.children[1:] %}
                    <li class="{% if nav_item.active%}current{% endif %}">
                        <a href="{{ nav_item.url|url }}">{{ nav_item.title }}</a>
                    </li>
                {% endfor %}
                </ul>
            </li>
        {% else %}
            <li class="{% if nav_item.active%}current{% endif %}">
                <a href="{{ nav_item.url|url }}">{{ nav_item.title }}</a>
            </li>
        {% endif %}
    {% endfor %}
    </ul>
{% endif %} 

chrissimpkins avatar Oct 21 '19 18:10 chrissimpkins

@chrissimpkins do you plan to implement this feature? When could it be available?

andre2007 avatar Oct 22 '19 13:10 andre2007

Unfortunately I won't be able to do it myself in the near term but would be happy to consider a pull request if anyone out there has an interest in it. I really apologize. I am just bogged down with higher priority work.

chrissimpkins avatar Oct 22 '19 14:10 chrissimpkins