Skip to content

Commit

Permalink
speeds up compile by roughly 160x
Browse files Browse the repository at this point in the history
  • Loading branch information
hry-gh committed Aug 3, 2024
1 parent 873f6de commit 3fbe722
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<nav role="navigation" class="pr-2">
<ul>
{%- block menu -%}
{%- set index = get_section(path="_index.md") -%}
{%- set index = get_section(path="_index.md", metadata_only=true) -%}
{%- for subsectionPath in index.subsections | sort -%}
{%- set subsection = get_section(path=subsectionPath) -%}
{{ macros::render_subsection(currentPage=pageOrSubsection, subsection=subsection, depth=0) -}}
Expand Down
26 changes: 13 additions & 13 deletions templates/macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
{%- set myParent = subsection.ancestors | last %}
{%- endif %}

{%- set myParentSection = get_section(path=myParent) -%}
{%- set myParentSection = get_section(path=myParent, metadata_only=true) -%}

{%- set subsectionParentUrl = subsection.ancestors | last %}
{%- set subsectionParent = get_section(path=subsectionParentUrl) %}
{%- set subsectionParent = get_section(path=subsectionParentUrl, metadata_only=true) %}

{%- set renderAll = false %}
{%- for page in currentPage.ancestors %}
{%- set iteratorSection = get_section(path=page) %}
{%- set iteratorSection = get_section(path=page, metadata_only=true) %}
{%- if iteratorSection.path == subsectionParent.path %}
{%- set_global renderAll = true %}
{%- break %}
Expand Down Expand Up @@ -59,7 +59,7 @@
{%- if subsection.subsections -%}
<ul>
{%- for lowerSubPath in subsection.subsections | sort-%}
{% set lowerSubsection = get_section(path=lowerSubPath) %}
{% set lowerSubsection = get_section(path=lowerSubPath, metadata_only=true) %}
{{- self::render_subsection(currentPage = currentPage, subsection=lowerSubsection, depth=depth+1) -}}
{%- endfor -%}
</ul>
Expand All @@ -78,7 +78,7 @@
{% macro render_subsection_pages(page, currentPage, subsection, depth, currentParent) %}
{%- set renderAll = false %}
{%- for page in currentPage.ancestors %}
{%- set iteratorSection = get_section(path=page) %}
{%- set iteratorSection = get_section(path=page, metadata_only=true) %}
{%- if iteratorSection.path == subsection.path %}
{%- set_global renderAll = true %}
{%- break %}
Expand Down Expand Up @@ -113,7 +113,7 @@
{% macro render_breadcrumbs(currentPage) %}
{% set ancestorLength = currentPage.ancestors | length %}
{% for i in range(start=2, end=ancestorLength) %}
{% set ancestorSection = get_section(path=currentPage.ancestors[i]) %}
{% set ancestorSection = get_section(path=currentPage.ancestors[i], metadata_only=true) %}
<a href="{{ ancestorSection.permalink | safe }}">
{{ ancestorSection.title }}
</a>
Expand All @@ -126,7 +126,7 @@
{% macro render_parent_type(page, recursive=true) %}
{%- if page.extra.parent_type %}
{%- set lookup = "objects" ~ page.extra.parent_type ~ "/_index.md" %}
{%- set url = get_section(path=lookup) %}
{%- set url = get_section(path=lookup, metadata_only=true) %}
{%- if recursive %}
{{- self::render_parent_type(page=url) }}
{%- endif %}
Expand All @@ -146,7 +146,7 @@
{%- else %}
{%- set parent = page.ancestors | last %}
{%- endif %}
{%- set parentSection = get_section(path=parent) %}
{%- set parentSection = get_section(path=parent, metadata_only=true) %}
{%- if recursive %}
{{- self::render_parent_type(page=parentSection) }}
{%- endif %}
Expand All @@ -166,7 +166,7 @@
{% set firstChar = type | split(pat="") | nth(n = 1) -%}
{% if firstChar == "/" -%}
{% set lookup = "objects" ~ type ~ "/_index.md" -%}
{% set url = get_section(path=lookup) -%}
{% set url = get_section(path=lookup, metadata_only=true) -%}
<a href="{{ url.permalink | safe}}" class="code-title type">{{url.title}}</a>
{%- else -%}
{{type}}
Expand All @@ -188,7 +188,7 @@

{% macro render_inherited_procs(parent_type) %}
{% set lookup = "objects" ~ parent_type ~ "/_index.md" %}
{% set url = get_section(path=lookup) %}
{% set url = get_section(path=lookup, metadata_only=true) %}
{% for possibleProcPageUrl in url.subsections %}
{% set possibleProcPage = get_section(path=possibleProcPageUrl) %}
{% if possibleProcPage.title == "proc" %}
Expand All @@ -215,7 +215,7 @@

{% macro render_inherited_procs_page(page) %}
{% set parent = page.ancestors | last %}
{% set parentSection = get_section(path=parent) %}
{% set parentSection = get_section(path=parent, metadata_only=true) %}
{% if parentSection.extra.parent_type %}
<h3 class="text-xl">Inherited Procs:</h3>
{{ self::render_inherited_procs(parent_type=parentSection.extra.parent_type) }}
Expand All @@ -224,7 +224,7 @@ <h3 class="text-xl">Inherited Procs:</h3>

{% macro render_inherited_vars(parent_type) %}
{% set lookup = "objects" ~ parent_type ~ "/_index.md" %}
{% set url = get_section(path=lookup) %}
{% set url = get_section(path=lookup, metadata_only=true) %}
{% for possibleVarPageUrl in url.subsections %}
{% set possibleVarPage = get_section(path=possibleVarPageUrl) %}
{% if possibleVarPage.title == "var" %}
Expand All @@ -251,7 +251,7 @@ <h3 class="text-xl">Inherited Procs:</h3>

{% macro render_inherited_vars_page(page) %}
{% set parent = page.ancestors | last %}
{% set parentSection = get_section(path=parent) %}
{% set parentSection = get_section(path=parent, metadata_only=true) %}
{% if parentSection.extra.parent_type %}
<h3 class="text-xl">Inherited Vars:</h3>
{{ self::render_inherited_vars(parent_type=parentSection.extra.parent_type) }}
Expand Down
6 changes: 3 additions & 3 deletions templates/toml.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
{%- set num = page.ancestors | length %}
{%- set sub = num - 1 %}
{%- set parent = page.ancestors | nth(n=sub - 1) %}
{%- set parentSection = get_section(path=parent) %}
{%- set directParent = get_section(path=page.ancestors | last) -%}
{%- set parentSection = get_section(path=parent, metadata_only=true) %}
{%- set directParent = get_section(path=page.ancestors | last, metadata_only=true) -%}
{%- if directParent.title == "proc" -%}
{%- set title = page.title ~ " (" ~ parentSection.title ~ " Proc)" -%}
{%- elif directParent.title == "var" -%}
Expand All @@ -35,7 +35,7 @@
url_prefix = "{{config.base_url | safe }}"
frontmatter_handling = "Omit"

{% set index = get_section(path="_index.md") -%}
{% set index = get_section(path="_index.md", metadata_only=true) -%}
{% for subsection in index.subsections -%}
{{ self::toml_recurse(subsectionPath=subsection) -}}
{% endfor %}

0 comments on commit 3fbe722

Please sign in to comment.