diff --git a/templates/feed.xml b/templates/feed.xml index dc7b356b8..ae19e1e8f 100644 --- a/templates/feed.xml +++ b/templates/feed.xml @@ -20,6 +20,7 @@ {{ macros::escape_hbs(input=page.title) | safe }} {%- set num_comps = page.components | length %} + {%- if num_comps < 4 %}{{ throw(message="Missing date in 'path' key, required format: '[inside-rust/]YYYY/MM/DD/slug-of-your-choice'") }}{% endif %} {%- set year = page.components | nth(n=num_comps - 4) %} {%- set month = page.components | nth(n=num_comps - 3) %} {%- set day = page.components | nth(n=num_comps - 2) %} diff --git a/templates/index.html b/templates/index.html index 786910b4e..f6c79456c 100644 --- a/templates/index.html +++ b/templates/index.html @@ -27,6 +27,7 @@ {%- set rev_pages = section.pages | reverse %} {%- for page in rev_pages %} {%- set num_comps = page.components | length %} + {%- if num_comps < 4 %}{{ throw(message="Missing date in 'path' key, required format: '[inside-rust/]YYYY/MM/DD/slug-of-your-choice'") }}{% endif %} {%- set year = page.components | nth(n=num_comps - 4) | int %} {%- set month = page.components | nth(n=num_comps - 3) | int %} {%- set day = page.components | nth(n=num_comps - 2) | int %} diff --git a/templates/page.html b/templates/page.html index 76091ddf0..ae6c8e267 100644 --- a/templates/page.html +++ b/templates/page.html @@ -2,6 +2,7 @@ {% extends "layout.html" -%} {% block page -%} {% set num_comps = page.components | length -%} +{% if num_comps < 4 %}{{ throw(message="Missing date in 'path' key, required format: '[inside-rust/]YYYY/MM/DD/slug-of-your-choice'") }}{% endif -%} {% set year = page.components | nth(n=num_comps - 4) | int -%} {% set month = page.components | nth(n=num_comps - 3) | int -%} {% set day = page.components | nth(n=num_comps - 2) | int -%} diff --git a/templates/releases.html b/templates/releases.html index fcfaa100b..5cc1d55c2 100644 --- a/templates/releases.html +++ b/templates/releases.html @@ -26,6 +26,7 @@ {%- set rev_pages = section.pages | reverse %} {%- for page in rev_pages %} {%- set num_comps = page.components | length %} + {%- if num_comps < 4 %}{{ throw(message="Missing date in 'path' key, required format: '[inside-rust/]YYYY/MM/DD/slug-of-your-choice'") }}{% endif %} {%- set year = page.components | nth(n=num_comps - 4) | int %} {%- set month = page.components | nth(n=num_comps - 3) | int %} {%- set day = page.components | nth(n=num_comps - 2) | int %}