Optimize rendering of the documentation site (#8020)

Merge pull request 8020
This commit is contained in:
Ashwin Maroli 2020-02-25 05:14:11 +05:30 committed by GitHub
parent 002ed48fd8
commit 68066ce268
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 226 additions and 302 deletions

View File

@ -1,4 +1,4 @@
{% if site.google_analytics_id %}
{% if site.google_analytics_id -%}
<!-- Google Analytics (https://www.google.com/analytics) -->
<script>
!function(j,e,k,y,l,L){j.GoogleAnalyticsObject=y,j[y]||(j[y]=function(){
@ -8,6 +8,5 @@
ga('create', '{{ site.google_analytics_id }}', 'jekyllrb.com');
ga('send', 'pageview');
</script>
{% endif %}
{% endif -%}

View File

@ -1,17 +1,15 @@
<div class="unit one-fifth hide-on-mobiles">
<aside>
{% for section in site.data.docs_nav %}
{% for section in site.data.docs_nav -%}
<h4>{{ section.title }}</h4>
<ul>
{% for item in section.docs %}
{% assign p = site.documents | where: "url", item.link | first %}
<li {%- if page.url == p.url %} class="current" {%- endif %}>
<a href="{{ p.url }}">
{{ p.menu_name | default: p.title }}
</a>
</li>
{% endfor %}
{%- for item in section.docs -%}
{%- assign p = site.documents | where: "url", item.link | first %}
<li {%- if page.url == p.url %} class="current" {%- endif -%}><a href="{{ p.url }}">
{{- p.menu_name | default: p.title -}}
</a></li>
{%- endfor %}
</ul>
{% endfor %}
{% endfor -%}
</aside>
</div>

View File

@ -1,15 +1,15 @@
<div class="docs-nav-mobile unit whole show-on-mobiles">
<select onchange="if (this.value) window.location.href=this.value">
<option value="">Navigate the docs…</option>
{% for section in site.data.docs_nav %}
{% for section in site.data.docs_nav -%}
<optgroup label="{{ section.title }}">
{% for item in section.docs %}
{% assign p = site.documents | where: "url", item.link | first %}
<option value="{{ p.url }}">
{{ p.menu_name | default: p.title }}
</option>
{% endfor %}
{%- for item in section.docs -%}
{% assign p = site.documents | where: "url", item.link | first %}
<option value="{{ p.url }}">
{{- p.menu_name | default: p.title -}}
</option>
{%- endfor %}
</optgroup>
{% endfor %}
{% endfor -%}
</select>
</div>

View File

@ -7,12 +7,12 @@
</tr>
</thead>
<tbody>
{% for var in include.scope %}
{% for var in include.scope -%}
<tr>
<td><p><code>{{ var.name }}</code></p></td>
<td><p>{{- var.description -}}</p></td>
</tr>
{% endfor %}
{% endfor -%}
</tbody>
</table>
</div>

View File

@ -9,23 +9,19 @@
</h1>
</div>
<nav class="main-nav hide-on-mobiles">
{% include primary-nav-items.html %}
{% include primary-nav-items.html -%}
</nav>
<div class="search hide-on-mobiles">
{% include search/input.html %}
{% include search/input.html -%}
</div>
<div class="meta hide-on-mobiles">
<ul>
<li>
<a href="{{ site.repository }}/releases/tag/v{{ site.version }}">v{{ site.version }}</a>
</li>
<li>
<a href="{{ site.repository }}">GitHub</a>
</li>
<li><a href="{{ site.repository }}/releases/tag/v{{ site.version }}">v{{ site.version }}</a></li>
<li><a href="{{ site.repository }}">GitHub</a></li>
</ul>
</div>
</div>
<nav class="mobile-nav show-on-mobiles">
{% include mobile-nav-items.html %}
{% include mobile-nav-items.html -%}
</nav>
</header>

View File

@ -1,18 +1,14 @@
<ul>
{% for p in site.data.primary_nav %}
{%- if p.show_on_mobile %}
{% for p in site.data.primary_nav -%}
{% if p.show_on_mobile -%}
<li
{%- if p.link == '/' -%}
{% if page.url == '/' %} class="current" {%- endif %}
{%- else -%}
{% if page.url contains p.link %} class="current" {%- endif %}
{%- endif -%}
>
<a href="{{ p.link }}">{{ p.title }}</a>
</li>
{%- endif %}
{% endfor %}
<li>
<a href="{{ site.repository }}">GitHub</a>
</li>
{%- if page.url == '/' %} class="current" {% endif -%}
{% else -%}
{%- if page.url contains p.link %} class="current" {% endif -%}
{% endif -%}
><a href="{{ p.link }}">{{ p.title }}</a></li>
{% endif -%}
{% endfor -%}
<li><a href="{{ site.repository }}">GitHub</a></li>
</ul>

View File

@ -10,24 +10,24 @@
</ul>
<h4>Recent Releases</h4>
<ul>
{% for post in site.categories.release limit:5 %}
<li {%- if page.title == post.title %} class="current" {%- endif %}>
{% for post in site.categories.release limit:5 -%}
<li {% if page.title == post.title %} class="current"{% endif %}>
<a href="{{ post.url }}">Version {{ post.version }}</a>
</li>
{% endfor %}
{% endfor -%}
<li>
<a href="/docs/history/">History »</a>
</li>
</ul>
<h4>Other News</h4>
<ul>
{% for post in site.posts %}
{% unless post.categories contains 'release' %}
<li {%- if page.title == post.title %} class="current" {%- endif %}>
<a href="{{ post.url }}">{{ post.title }}</a>
</li>
{% endunless %}
{% endfor %}
{% for post in site.posts -%}
{% unless post.categories contains 'release' -%}
<li {%- if page.title == post.title %} class="current" {%- endif %}>
<a href="{{ post.url }}">{{ post.title }}</a>
</li>
{% endunless -%}
{% endfor -%}
</ul>
</aside>
</div>

View File

@ -3,9 +3,9 @@
<option value="">Navigate the blog…</option>
<option value="/news/">Home</option>
<optgroup label="posts">
{% for post in site.posts %}
{% for post in site.posts -%}
<option value="{{ post.url }}">{{ post.title }}</option>
{% endfor %}
{% endfor -%}
</optgroup>
</select>
</div>

View File

@ -1,25 +1,25 @@
<article>
<h2>
<a href="{{ post.url }}">
{{ post.title }}
{{- post.title -}}
</a>
</h2>
<span class="post-category">
<span class="label">
{{ post.categories | array_to_sentence_string }}
{{- post.categories | array_to_sentence_string -}}
</span>
</span>
<div class="post-meta">
<span class="post-date">
{{ post.date | date_to_string }}
{{- post.date | date_to_string -}}
</span>
{% assign author = post.author %}
{% assign author = post.author -%}
<a href="https://github.com/{{ author }}" class="post-author">
{% avatar user=author size=24 %}
{% avatar user=author size=24 -%}
{{ author }}
</a>
</div>
<div class="post-content">
{{ post.content }}
{{- post.content -}}
</div>
</article>

View File

@ -1,13 +1,11 @@
<ul>
{% for p in site.data.primary_nav %}
{% for p in site.data.primary_nav -%}
<li
{%- if p.link == '/' -%}
{% if page.url == p.link %} class="current" {%- endif %}
{%- else -%}
{% if page.url contains p.link %} class="current" {%- endif %}
{%- endif -%}
>
<a href="{{ p.link }}">{{ p.title }}</a>
</li>
{% endfor %}
{% if page.url == p.link %} class="current" {%- endif -%}
{% else -%}
{% if page.url contains p.link %} class="current" {%- endif -%}
{% endif -%}
><a href="{{ p.link }}">{{ p.title }}</a></li>
{% endfor -%}
</ul>

View File

@ -1,39 +1,39 @@
{% comment %}
{%- comment -%}
Map grabs the tutorials sections, giving us an array of arrays. Join, flattens all
the items to a comma delimited string. Split turns it into an array again.
{% endcomment %}
{% assign tutorials = site.data.tutorials | map: 'tutorials' | join: ',' | split: ',' %}
{%- endcomment -%}
{%- assign tutorials = site.data.tutorials | map: 'tutorials' | join: ',' | split: ',' -%}
{% comment %}
{%- comment -%}
Because this is built for every page, lets find where we are in the ordered
document list by comparing url strings. Then if there's something previous or
next, lets build a link to it.
{% endcomment %}
{%- endcomment -%}
{% for tutorial in tutorials %}
{% assign tutorial_url = tutorial | prepend:"/tutorials/" | append:"/" %}
{% if tutorial_url == page.url %}
<div class="section-nav">
<div class="left align-right">
{% if forloop.first %}
<span class="prev disabled">Back</span>
{% else %}
{% assign previous = forloop.index0 | minus: 1 %}
{% assign previous_page = tutorials[previous] | prepend:"/tutorials/" | append:"/" %}
<a href="{{ previous_page }}" class="prev">Back</a>
{% endif %}
</div>
<div class="right align-left">
{% if forloop.last %}
<span class="next disabled">Next</span>
{% else %}
{% assign next = forloop.index0 | plus: 1 %}
{% assign next_page = tutorials[next] | prepend:"/tutorials/" | append:"/" %}
<a href="{{ next_page }}" class="next">Next</a>
{% endif %}
</div>
{% for tutorial in tutorials -%}
{% assign tutorial_url = tutorial | prepend:"/tutorials/" | append:"/" -%}
{% if tutorial_url == page.url -%}
<div class="section-nav">
<div class="left align-right">
{% if forloop.first -%}
<span class="prev disabled">Back</span>
{% else -%}
{% assign previous = forloop.index0 | minus: 1 -%}
{% assign previous_page = tutorials[previous] | prepend:"/tutorials/" | append:"/" -%}
<a href="{{ previous_page }}" class="prev">Back</a>
{% endif -%}
</div>
<div class="clear"></div>
{% break %}
{% endif %}
{% endfor %}
<div class="right align-left">
{% if forloop.last -%}
<span class="next disabled">Next</span>
{% else -%}
{% assign next = forloop.index0 | plus: 1 -%}
{% assign next_page = tutorials[next] | prepend:"/tutorials/" | append:"/" -%}
<a href="{{ next_page }}" class="next">Next</a>
{% endif -%}
</div>
</div>
<div class="clear"></div>
{% break -%}
{% endif -%}
{% endfor -%}

View File

@ -1,65 +1,34 @@
{% assign docs = site.docs | where_exp: "doc", "doc.url contains '/step-by-step/'" %}
{% assign docs = site.docs | where_exp: "doc", "doc.url contains '/step-by-step/'" -%}
{% for tutorial in tutorials %}
{% assign tutorial_url = tutorial | prepend:"/tutorials/" | append:"/" %}
{% if tutorial_url == page.url %}
{% for doc in docs -%}
{% if doc.url == page.url -%}
<div class="section-nav">
<div class="left align-right">
{% if forloop.first %}
<span class="prev disabled">Back</span>
{% else %}
{% assign previous = forloop.index0 | minus: 1 %}
{% assign previous_page = tutorials[previous] | prepend:"/tutorials/" | append:"/" %}
<a href="{{ previous_page }}" class="prev">Back</a>
{% endif %}
{% if forloop.first -%}
<span class="prev disabled">Back</span>
{% else -%}
{% assign previous = forloop.index0 | minus: 1 -%}
<a href="{{ docs[previous].url }}" class="prev">Back</a>
{% endif -%}
</div>
<div class="right align-left">
{% if forloop.last %}
<span class="next disabled">Next</span>
{% else %}
{% assign next = forloop.index0 | plus: 1 %}
{% assign next_page = tutorials[next] | prepend:"/tutorials/" | append:"/" %}
<a href="{{ next_page }}" class="next">Next</a>
{% endif %}
{% if forloop.last -%}
<span class="next disabled">Next</span>
{% else -%}
{% assign next = forloop.index0 | plus: 1 -%}
<a href="{{ docs[next].url }}" class="next">Next</a>
{% endif -%}
</div>
</div>
<div class="clear"></div>
{% break %}
{% endif %}
{% endfor %}
{% for doc in docs %}
{% if doc.url == page.url %}
<div class="section-nav">
<div class="left align-right">
{% if forloop.first %}
<span class="prev disabled">Back</span>
{% else %}
{% assign previous = forloop.index0 | minus: 1 %}
<a href="{{ docs[previous].url }}" class="prev">Back</a>
{% endif %}
</div>
<div class="right align-left">
{% if forloop.last %}
<span class="next disabled">Next</span>
{% else %}
{% assign next = forloop.index0 | plus: 1 %}
<a href="{{ docs[next].url }}" class="next">Next</a>
{% endif %}
</div>
</div>
<div class="clear"></div>
{% break %}
{% endif %}
{% endfor %}
{% break -%}
{% endif -%}
{% endfor -%}
<ol class="step-nav">
{% for step in docs %}
<li {% if step.url == page.url %}class="current"{% endif %}>
<a href="{{ step.url }}">
{{ step.title }}
</a>
</li>
{% endfor %}
{% for step in docs -%}
<li {%- if step.url == page.url %} class="current"{% endif %}><a href="{{ step.url }}">
{{- step.title -}}
</a></li>
{% endfor -%}
</ol>

View File

@ -1,10 +1,16 @@
<div class="unit one-fifth hide-on-mobiles">
<aside>
{% for section in site.data.tutorials %}
<h4>{{ section.title }}</h4>
{% include tutorials_ul.html items=section.tutorials %}
{% endfor %}
{% for section in site.data.tutorials -%}
<h4>{{ section.title }}</h4>
<ul>
{% for item in section.tutorials -%}
{% assign item_url = item | prepend:"/tutorials/" | append:"/" -%}
{% assign p = site.tutorials | where:"url", item_url | first -%}
<li {%- if item_url == page.url %} class="current" {%- endif %}><a href="{{ p.url }}">
{{- p.title -}}
</a></li>
{% endfor -%}
</ul>
{% endfor -%}
</aside>
</div>

View File

@ -1,10 +1,14 @@
<div class="docs-nav-mobile unit whole show-on-mobiles">
<select onchange="if (this.value) window.location.href=this.value">
<option value="">Navigate the tutorials…</option>
{% for section in site.data.tutorials %}
{% for section in site.data.tutorials -%}
<optgroup label="{{ section.title }}">
{% include tutorials_option.html items=section.tutorials %}
{% for item in section.tutorials -%}
{% assign item_url = item | prepend:"/tutorials/" | append:"/" -%}
{% assign tutorial = site.tutorials | where: "url", item_url | first -%}
<option value="{{ tutorial.url }}">{{ tutorial.title }}</option>
{% endfor -%}
</optgroup>
{% endfor %}
{% endfor -%}
</select>
</div>

View File

@ -1,5 +0,0 @@
{% for item in include.items %}
{% assign item_url = item | prepend:"/tutorials/" | append:"/" %}
{% assign tutorial = site.tutorials | where: "url", item_url | first %}
<option value="{{ tutorial.url }}">{{ tutorial.title }}</option>
{% endfor %}

View File

@ -1,7 +0,0 @@
<ul>
{% for item in include.items %}
{% assign item_url = item | prepend:"/tutorials/" | append:"/" %}
{% assign p = site.tutorials | where:"url", item_url | first %}
<li {%- if item_url == page.url %} class="current" {%- endif %}><a href="{{ p.url }}">{{ p.title }}</a></li>
{% endfor %}
</ul>

View File

@ -1,13 +1,13 @@
{% include top.html %}
{%- include top.html -%}
<body class="wrap">
{% include header.html %}
{%- include header.html -%}
{{ content }}
{{- content -}}
{% include footer.html %}
{% include anchor_links.html %}
{% include analytics.html %}
{% include search/script.html %}
{%- include footer.html -%}
{%- include anchor_links.html -%}
{%- include analytics.html -%}
{%- include search/script.html -%}
</body>
</html>

View File

@ -2,24 +2,20 @@
layout: default
---
<section class="docs">
<div class="grid">
{% include docs_contents_mobile.html %}
<div class="unit four-fifths">
<article>
<div class="improve right hide-on-mobiles">
<a data-proofer-ignore href="https://github.com/jekyll/jekyll/edit/master/docs/{{ page.path }}"><i class="fa fa-pencil"></i> &nbsp;Improve this page</a>
</div>
<h1>{{ page.title }}</h1>
{{ content }}
</article>
</div>
{% include docs_contents.html %}
<div class="clear"></div>
<section class="docs">
<div class="grid">
{% include docs_contents_mobile.html -%}
<div class="unit four-fifths">
<article>
<div class="improve right hide-on-mobiles">
<a data-proofer-ignore href="https://github.com/jekyll/jekyll/edit/master/docs/{{ page.path }}"><i
class="fa fa-pencil"></i> &nbsp;Improve this page</a>
</div>
<h1>{{ page.title }}</h1>
{{ content }}
</article>
</div>
</section>
{% include docs_contents.html -%}
<div class="clear"></div>
</div>
</section>

View File

@ -2,18 +2,13 @@
layout: default
---
<section class="news">
<div class="grid">
{% include news_contents_mobile.html %}
<div class="unit four-fifths">
{{ content }}
</div>
{% include news_contents.html %}
<div class="clear"></div>
<section class="news">
<div class="grid">
{% include news_contents_mobile.html -%}
<div class="unit four-fifths">
{{- content -}}
</div>
</section>
{% include news_contents.html -%}
<div class="clear"></div>
</div>
</section>

View File

@ -12,17 +12,17 @@ layout: news
</h2>
<span class="post-category">
<span class="label">
{{ page.categories | array_to_sentence_string }}
{{- page.categories | array_to_sentence_string -}}
</span>
</span>
<div class="post-meta">
<span class="post-date">
{{ page.date | date_to_string }}
{{- page.date | date_to_string -}}
</span>
{% assign author = page.author %}
{% assign author = page.author -%}
<a href="https://github.com/{{ author }}" class="post-author">
{% avatar user=author size=24 %}
{{ author }}
{% avatar user=author size=24 -%}
{{- author -}}
</a>
</div>
<div class="post-content">

View File

@ -4,15 +4,12 @@ layout: default
<section class="standalone">
<div class="grid">
<div class="unit whole">
<article>
<h1>{{ page.title }}</h1>
{{ content }}
</article>
</div>
<div class="clear"></div>
</div>
</section>

View File

@ -1,26 +1,21 @@
---
layout: default
---
<section class="docs">
<div class="grid">
{% include docs_contents_mobile.html %}
<div class="unit four-fifths">
<article>
<div class="improve right hide-on-mobiles">
<a data-proofer-ignore href="https://github.com/jekyll/jekyll/edit/master/docs/{{ page.path }}"><i class="fa fa-pencil"></i> &nbsp;Improve this page</a>
</div>
<h1>Step by Step Tutorial</h1>
<h2>{{ page.position }}. {{ page.title }}</h2>
{{ content }}
{% include step-index.html %}
</article>
</div>
{% include docs_contents.html %}
<div class="clear"></div>
<section class="docs">
<div class="grid">
{% include docs_contents_mobile.html -%}
<div class="unit four-fifths">
<article>
<div class="improve right hide-on-mobiles">
<a data-proofer-ignore href="https://github.com/jekyll/jekyll/edit/master/docs/{{ page.path }}"><i class="fa fa-pencil"></i> &nbsp;Improve this page</a>
</div>
<h1>Step by Step Tutorial</h1>
<h2>{{ page.position }}. {{ page.title }}</h2>
{{ content }}
{% include step-index.html -%}
</article>
</div>
</section>
{% include docs_contents.html -%}
<div class="clear"></div>
</div>
</section>

View File

@ -2,26 +2,21 @@
layout: default
---
<section class="docs">
<div class="grid">
{% include tutorials_contents_mobile.html %}
<div class="unit four-fifths">
<article>
<div class="improve right hide-on-mobiles">
<a href="https://github.com/jekyll/jekyll/edit/master/docs/{{ page.path }}"><i
class="fa fa-pencil"></i> &nbsp;Improve this page</a>
</div>
<h1>{{ page.title }}</h1>
{{ content }}
{% include section_nav_tutorials.html %}
</article>
</div>
{% include tutorials_contents.html %}
<div class="clear"></div>
<section class="docs">
<div class="grid">
{%- include tutorials_contents_mobile.html -%}
<div class="unit four-fifths">
<article>
<div class="improve right hide-on-mobiles">
<a href="https://github.com/jekyll/jekyll/edit/master/docs/{{ page.path }}"><i
class="fa fa-pencil"></i> &nbsp;Improve this page</a>
</div>
<h1>{{ page.title }}</h1>
{{- content -}}
{%- include section_nav_tutorials.html -%}
</article>
</div>
</section>
{%- include tutorials_contents.html -%}
<div class="clear"></div>
</div>
</section>

View File

@ -18,18 +18,10 @@ sitemap: false
<p>The resource you requested was not found. Here are some links to help you find your way:</p>
<nav class="main-nav">
<ul>
<li>
<a href="/">Home</a>
</li>
<li>
<a href="/docs/home/">Documentation</a>
</li>
<li>
<a href="/news/">News</a>
</li>
<li>
<a href="/help/">Help</a>
</li>
<li><a href="/">Home</a></li>
<li><a href="/docs/home/">Documentation</a></li>
<li><a href="/news/">News</a></li>
<li><a href="/help/">Help</a></li>
</ul>
</nav>
</div>

View File

@ -5,6 +5,6 @@ permalink: /news/
author: all
---
{% for post in site.posts %}
{% include news_item.html %}
{% endfor %}
{% for post in site.posts -%}
{% include news_item.html -%}
{% endfor -%}

View File

@ -5,6 +5,6 @@ permalink: /news/releases/
author: all
---
{% for post in site.categories.release %}
{% include news_item.html %}
{% endfor %}
{% for post in site.categories.release -%}
{% include news_item.html -%}
{% endfor -%}

View File

@ -9,18 +9,18 @@ redirect_from:
<p>Jekyll is used for all kinds of usecases. Here's some of our favorites:</p>
<ul class="showcase" id="showcase">
{% for s in site.data.showcase reversed %}
<li>
<a href="{{ s.url }}" target="_blank">
<figure>
<div class="imageWrapper">
<img class="b-lazy" src="/img/spacer.gif" alt="{{ s.name }}">
</div>
<figcaption>{{ s.name }}</figcaption>
</figure>
</a>
</li>
{% endfor %}
{% for s in site.data.showcase reversed -%}
<li>
<a href="{{ s.url }}" target="_blank">
<figure>
<div class="imageWrapper">
<img class="b-lazy" src="/img/spacer.gif" alt="{{ s.name }}">
</div>
<figcaption>{{ s.name }}</figcaption>
</figure>
</a>
</li>
{% endfor -%}
<li class="spacer"></li>
</ul>