-
-
Notifications
You must be signed in to change notification settings - Fork 104
doc index improvements #177
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
Conversation
708022d to
ab19cb2
Compare
_includes/doc-index.html
Outdated
| {% for page in all_docs %}{% if page.url == sub.url -%} | ||
| <li><a href="{{ sub.url }}">{{ page.title }}</a></li> | ||
| {%- endif %}{% endfor %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have only one opening/closing operator per line? In other words:
{% for page in all_docs %}
{% if page.url == sub.url -%}
<li><a href="{{ sub.url }}">{{ page.title }}</a></li>
{%- endif %}
{% endfor %}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only thing I want to confirm before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Neat trick! I didn't know about it.
Yes, I noticed that too. In general, the best solution (after the improvements you've made here) would be to minify our output. This method sounds like it might be promising, and there are many others discussed on the web.
Good catch. Thank you!
Ok, thank you. |
Mark single-line statements with '-' at the end, to strip blanks after
it - otherwise lines like {% assign ... %} will produce empty line in
the output.
Do the same with 'for' loops and embedded 'if' inside, but be careful to
not strip too much, to still insert newlines between list items (loop
iterations).
This is especially important for loops iterating many times (like,
enumerating the whole site.doc), otherwise the output may be a huge file
of mostly spaces and newlines. With translated repo included, I managed
to get about 800KB doc index file...
Furthermore, optimize external doc generation. Specifically - do
not iterate over the whole site.doc for external docs - those won't
match anyway. This saves about 2s of site build time.
Also, iterate over subpages/subpages3 once, not twice. This IMO makes
it easier to follow - it's more obvious the entry is either external doc
or not - but not both.
1. Distinguish doc index using appropriate language-specific permalink. Fortunately, doc-heading.html already sets 'doc_link' variable. 2. For translated doc, iterate over site.translated, instead of site.doc.
ab19cb2 to
41cc586
Compare
Make it produce less white spaces/empty lines and make it work with translated pages.
See individual commits for details.