Skip to content

Add support for sub sections (anchor links)#14

Open
arikfr wants to merge 1 commit into
GitbookIO:masterfrom
arikfr:patch-1
Open

Add support for sub sections (anchor links)#14
arikfr wants to merge 1 commit into
GitbookIO:masterfrom
arikfr:patch-1

Conversation

@arikfr
Copy link
Copy Markdown

@arikfr arikfr commented Nov 8, 2016

No description provided.

{% set relatedArticle = getArticleByPath(related) %}
{% if relatedArticle %}
<a href="{{ relatedArticle.path|resolveFile }}" class="list-group-item">{{ relatedArticle.title }}</a>
<a href="{{ relatedArticle.path|resolveFile }}{{ relatedArticle.anchor }}" class="list-group-item">{{ relatedArticle.title }}</a>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will find the first article with matching path, and use this article's anchor. But that's not really what we would like here. If we have several articles pointing to the same file, we should expect the related property to have the anchor included, so that related refer without ambiguity to a particular article.

So we should do something like getArticleByPathWithAnchor(related)... but this is not in the API. So I would not implement it until GitBook v4 is finished.

Do you have a use-case for this?

{% for article in part.articles %}
{% if article.path != readme.file.path %}
<a href="{{ article.path|resolveFile }}" class="list-group-item">
<a href="{{ article.path|resolveFile }}{{ article.anchor }}" class="list-group-item">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great. I'll happily merge this

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.

2 participants