1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-18 02:42:05 +03:00
wezterm/docs/_layouts/default.html
Wez Furlong b0f2edd711 checkpoint jekyll TOC weirdness
I'm committing this because it captures a repro for the situation
described across these two issues:

Refs: https://github.com/jekyll/jekyll-archives/issues/28
Refs: https://github.com/jekyll/jekyll/issues/6209

This commit has a workaround in place; to demonstrate the problem,
change this line of `_layouts/default.html`:

```
 {% include toc.html sanitize=true baseurl=p.url html=p_content %}
```

to:

```
 {% include toc.html sanitize=true baseurl=p.url html=p.content %}
```

Then navigate to various pages: the TOC in the LHS inconsistently
shows headers from different pages depending on the current page.
2019-06-23 23:06:33 -07:00

75 lines
3.1 KiB
HTML

<!DOCTYPE html>
<html lang="{{ site.lang | default: "en-US" }}">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
{% seo %}
<link rel="stylesheet" href="{{ "/assets/css/style.css?v=" | append: site.github.build_revision | relative_url }}">
</head>
<body>
<ul id="toc">
{% for p in site.html_pages %}
{% if p.url contains "toc.html" %}
{% else %}
<li><a href="{{ p.url }}">{{ p.title }}</a></li>
{% comment %}
This fine mess is a workaround for inconsistent values of page.content.
Relevant GH issues are:
https://github.com/jekyll/jekyll-archives/issues/28
https://github.com/jekyll/jekyll/issues/6209
The brief summary is that at the time that this layout is processed,
the various `page` objects may or may not have had their `content`
transformed into html. Those that have not been transformed will
still be in raw markdown, which we can transform to html but not
apply any other filters/plugins for highlighting or eg: octicons.
As a result, we manually test to see if the content looks like
html and apply a simple transformation to markdown, and then
convert any liquid open/close tags to html comments so that
they don't appear in our TOC.
{% endcomment %}
{% if p.content contains '<html>' %}
{% assign p_content = p.content %}
{% else %}
{% assign curlyend = '}' %}
{% assign p_content = p.content | markdownify | replace: "{%", "<!--" | replace: curlyend, "-->" %}
{% endif %}
{% include toc.html sanitize=true baseurl=p.url html=p_content %}
{% endif %}
{% endfor %}
</ul>
<div id="container" class="container-lg px-3 my-5 markdown-body">
{% if site.title and site.title != page.title %}
<h1><a href="{{ "/" | absolute_url }}">{{ site.title }}</a></h1>
{% endif %}
{% include anchor_headings.html html=content %}
<div class="footer border-top border-gray-light mt-5 pt-3 text-gray">
<a style="float:left" href="toc.html">Full Table of Contents</a>
<div class="text-right">
<a href="{{ site.github.repository_url }}">{{ site.github.repository_name }}</a> is maintained by <a href="{{ site.github.owner_url }}">{{ site.github.owner_name }}</a>.
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/anchor-js/4.1.0/anchor.min.js"
integrity="sha256-lZaRhKri35AyJSypXXs4o6OPFTbTmUoltBbDCbdzegg="
crossorigin="anonymous"></script>
<script>anchors.add();</script>
{% if site.google_analytics %}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '{{ site.google_analytics }}', 'auto');
ga('send', 'pageview');
</script>
{% endif %}
</body>
</html>