Render HTML tables at `/docs/permalinks/` using a data file (#9666)

Merge pull request 9666
This commit is contained in:
Ashwin Maroli 2024-09-22 23:51:59 +05:30 committed by GitHub
parent 0f03b31b85
commit f8a456d16e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 164 additions and 343 deletions

139
docs/_data/permalinks.yml Normal file
View File

@ -0,0 +1,139 @@
placeholders:
- name: year
desc: >-
Year from the post's filename with four digits. May be overridden via the document's
<code>date</code> front matter.
- name: short_year
desc: >-
Year from the post's filename without the century. (00..99) May be overridden via the
document's <code>date</code> front matter.
- name: month
desc: >-
Month from the post's filename. (01..12) May be overridden via the document's
<code>date</code> front matter.
- name: i_month
desc: >-
Month without leading zeros from the post's filename. May be overridden via the document's
<code>date</code> front matter.
- name: short_month
desc: >-
Three-letter month abbreviation, e.g. "Jan".
- name: long_month
intro_ver: "4.0"
desc: >-
Full month name, e.g. "January".
- name: day
desc: >-
Day of the month from the post's filename. (01..31) May be overridden via the document's
<code>date</code> front matter.
- name: i_day
desc: >-
Day of the month without leading zeros from the post's filename. May be overridden via the
document's <code>date</code> front matter.
- name: y_day
desc: >-
Ordinal day of the year from the post's filename, with leading zeros. (001..366)
- name: w_year
intro_ver: "4.0"
desc: >-
Week year which may differ from the month year for up to three days at the start of January
and end of December
- name: week
intro_ver: "4.0"
desc: >-
Week number of the current year, starting with the first week having a majority of its days
in January. (01..53)
- name: w_day
intro_ver: "4.0"
desc: >-
Day of the week, starting with Monday. (1..7)
- name: short_day
intro_ver: "4.0"
desc: >-
Three-letter weekday abbreviation, e.g. "Sun".
- name: long_day
intro_ver: "4.0"
desc: >-
Weekday name, e.g. "Sunday".
- name: hour
desc: >-
Hour of the day, 24-hour clock, zero-padded from the post's <code>date</code> front matter. (00..23)
- name: minute
desc: >-
Minute of the hour from the post's <code>date</code> front matter. (00..59)
- name: second
desc: >-
Second of the minute from the post's <code>date</code> front matter. (00..59)
- name: title
desc: >-
Title from the document's filename. May be overridden via the document's
<code>slug</code> front matter. Preserves case from the source.
- name: slug
desc: >-
Slugified title from the document's filename (any character except numbers and letters is
replaced as hyphen). May be overridden via the document's <code>slug</code> front matter.
- name: categories
desc: >-
The specified categories for this post. If a post has multiple categories, Jekyll will create
a hierarchy (e.g. <code>/category1/category2</code>). Also Jekyll automatically parses out
double slashes in the URLs, so if no categories are present, it will ignore this.
- name: slugified_categories
intro_ver: "4.1"
desc: >-
The specified categories for this post but <em>slugified</em>. If a category is a composite of
multiple words, Jekyll will downcase all alphabets and replace any non-alphanumeric character
with a hyphen. (e.g. <code>"Work 2 Progress"</code> will be converted into
<code>"work-2-progress"</code>). If a post has multiple categories, Jekyll will create
a hierarchy (e.g. <code>/work-2-progress/category2</code>). Also Jekyll automatically parses
out double slashes in the URLs, so if no categories are present, it will ignore this.
- name: output_ext
desc: >-
Extension of the output file. (Included by default and usually unnecessary.)
builtin_formats:
- name: date
format: "/:categories/:year/:month/:day/:title:output_ext"
- name: pretty
format: "/:categories/:year/:month/:day/:title/"
- name: ordinal
format: "/:categories/:year/:y_day/:title:output_ext"
- name: weekdate
intro_ver: "4.0"
format: "/:categories/:year/W:week/:short_day/:title:output_ext"
note: "<code>W</code> will be prefixed to the value of <code>:week</code>"
- name: none
format: "/:categories/:title:output_ext"
types:
documents:
- name: collection
desc: >-
Label of the containing collection.
- name: path
desc: >-
Path to the document relative to the collection's directory, including base filename of the document.
However, does not include the file extension.
- name: name
desc: >-
The document's base filename but slugified: downcased and every sequence of non-alphanumeric character
(including spaces) replaced by a hyphen.
- name: title
desc: >-
Takes on the value of front matter key <code>slug</code> if defined for the document. Otherwise takes
on the string value generated from the document's base filename by piping through the <code>slugify</code>
filter method with <code>pretty</code> option.<br/>
Regardless of the value taken, the case of the alphabets are preserved instead of being replaced with
lowercase counterparts.
- name: output_ext
desc: >-
Extension of the output file. (Included by default and usually unnecessary.)
pages:
- name: path
desc: >-
Path between the source directory and the base filename of the page.
- name: basename
desc: >-
The page's base filename.
- name: output_ext
desc: >-
Extension of the output file. (Included by default and usually unnecessary.)

View File

@ -55,237 +55,16 @@ Here's the full list of placeholders available:
</tr>
</thead>
<tbody>
{%- for entry in site.data.permalinks.placeholders %}
<tr>
<td>
<p><code>:year</code></p>
</td>
<td>
<p>
Year from the posts filename with four digits.
May be overridden via the documents <code>date</code> front matter.
</p>
</td>
</tr>
<tr>
<td>
<p><code>:short_year</code></p>
</td>
<td>
<p>
Year from the posts filename without the century. (00..99)
May be overridden via the documents <code>date</code> front matter.
</p>
</td>
</tr>
<tr>
<td>
<p><code>:month</code></p>
</td>
<td>
<p>
Month from the posts filename. (01..12)
May be overridden via the documents <code>date</code> front matter.
</p>
</td>
</tr>
<tr>
<td>
<p><code>:i_month</code></p>
</td>
<td>
<p>
Month without leading zeros from the posts filename. May be
overridden via the documents <code>date</code> front matter.
</p>
</td>
</tr>
<tr>
<td>
<p><code>:short_month</code></p>
</td>
<td>
<p>Three-letter month abbreviation, e.g. “Jan”.</p>
</td>
</tr>
<tr>
<td>
<p><code>:long_month</code></p>
<small>{% include docs_version_badge.html version="4.0" %}</small>
</td>
<td>
<p>Full month name, e.g. “January”.</p>
</td>
</tr>
<tr>
<td>
<p><code>:day</code></p>
</td>
<td>
<p>
Day of the month from the posts filename. (01..31)
May be overridden via the documents <code>date</code> front matter.
</p>
</td>
</tr>
<tr>
<td>
<p><code>:i_day</code></p>
</td>
<td>
<p>
Day of the month without leading zeros from the posts filename.
May be overridden via the documents <code>date</code> front matter.
</p>
</td>
</tr>
<tr>
<td>
<p><code>:y_day</code></p>
</td>
<td>
<p>Ordinal day of the year from the posts filename, with leading zeros. (001..366)</p>
</td>
</tr>
<tr>
<td>
<p><code>:w_year</code></p>
<small>{% include docs_version_badge.html version="4.0" %}</small>
</td>
<td>
<p>Week year which may differ from the month year for up to three days at the start of January and end of December</p>
</td>
</tr>
<tr>
<td>
<p><code>:week</code></p>
<small>{% include docs_version_badge.html version="4.0" %}</small>
</td>
<td>
<p>Week number of the current year, starting with the first week having a majority of its days in January. (01..53)</p>
</td>
</tr>
<tr>
<td>
<p><code>:w_day</code></p>
<small>{% include docs_version_badge.html version="4.0" %}</small>
</td>
<td>
<p>Day of the week, starting with Monday. (1..7)</p>
</td>
</tr>
<tr>
<td>
<p><code>:short_day</code></p>
<small>{% include docs_version_badge.html version="4.0" %}</small>
</td>
<td>
<p>Three-letter weekday abbreviation, e.g. “Sun”.</p>
</td>
</tr>
<tr>
<td>
<p><code>:long_day</code></p>
<small>{% include docs_version_badge.html version="4.0" %}</small>
</td>
<td>
<p>Weekday name, e.g. “Sunday”.</p>
</td>
</tr>
<tr>
<td>
<p><code>:hour</code></p>
</td>
<td>
<p>
Hour of the day, 24-hour clock, zero-padded from the posts
<code>date</code> front matter. (00..23)
</p>
</td>
</tr>
<tr>
<td>
<p><code>:minute</code></p>
</td>
<td>
<p>
Minute of the hour from the posts <code>date</code> front matter. (00..59)
</p>
</td>
</tr>
<tr>
<td>
<p><code>:second</code></p>
</td>
<td>
<p>
Second of the minute from the posts <code>date</code> front matter. (00..59)
</p>
</td>
</tr>
<tr>
<td>
<p><code>:title</code></p>
</td>
<td>
<p>
Title from the documents filename. May be overridden via
the documents <code>slug</code> front matter. Preserves case from the source.
</p>
</td>
</tr>
<tr>
<td>
<p><code>:slug</code></p>
</td>
<td>
<p>
Slugified title from the documents filename (any character
except numbers and letters is replaced as hyphen). May be
overridden via the documents <code>slug</code> front matter.
</p>
</td>
</tr>
<tr>
<td>
<p><code>:categories</code></p>
</td>
<td>
<p>
The specified categories for this post. If a post has multiple
categories, Jekyll will create a hierarchy (e.g. <code>/category1/category2</code>).
Also Jekyll automatically parses out double slashes in the URLs,
so if no categories are present, it will ignore this.
</p>
</td>
</tr>
<tr>
<td>
<p><code>:slugified_categories</code></p>
<small>{% include docs_version_badge.html version="4.1" %}</small>
</td>
<td>
<p>
The specified categories for this post but <em>slugified</em>. If a category is a
composite of multiple words, Jekyll will downcase all alphabets and replace any
non-alphanumeric character with a hyphen. (e.g. <code>"Work 2 Progress"</code>
will be converted into <code>"work-2-progress"</code>)
</p>
<p>
If a post has multiple categories, Jekyll will create a hierarchy
(e.g. <code>/work-2-progress/category2</code>).
Also Jekyll automatically parses out double slashes in the URLs,
so if no categories are present, it will ignore this.
</p>
</td>
</tr>
<tr>
<td>
<p><code>:output_ext</code></p>
</td>
<td>
<p>Extension of the output file. (Included by default and usually unnecessary.)</p>
<td><p><code>:{{ entry.name }}</code></p>
{%- if entry.intro_ver -%}
<small>{% include docs_version_badge.html version = entry.intro_ver %}</small>
{%- endif -%}
</td>
<td><p>{{ entry.desc }}</p></td>
</tr>
{%- endfor %}
</tbody>
</table>
</div>
@ -303,50 +82,22 @@ For posts, Jekyll also provides the following built-in styles for convenience:
</tr>
</thead>
<tbody>
{%- for entry in site.data.permalinks.builtin_formats %}
<tr>
<td>
<p><code>date</code></p>
<td><p><code>{{ entry.name }}</code></p>
{%- if entry.intro_ver -%}
<small>{% include docs_version_badge.html version = entry.intro_ver %}</small>
{%- endif -%}
</td>
<td>
<p><code>/:categories/:year/:month/:day/:title:output_ext</code></p>
</td>
</tr>
<tr>
<td>
<p><code>pretty</code></p>
</td>
<td>
<p><code>/:categories/:year/:month/:day/:title/</code></p>
</td>
</tr>
<tr>
<td>
<p><code>ordinal</code></p>
</td>
<td>
<p><code>/:categories/:year/:y_day/:title:output_ext</code></p>
</td>
</tr>
<tr>
<td>
<p><code>weekdate</code></p>
<small>{% include docs_version_badge.html version="4.0" %}</small>
</td>
<td>
<p>
<code>/:categories/:year/W:week/:short_day/:title:output_ext</code><br/>
<small>(<code>W</code> will be prefixed to the value of <code>:week</code>)</small>
<p><code>{{ entry.format }}</code>
{%- if entry.note -%}<br/>
<small>({{ entry.note }})</small>
{%- endif -%}
</p>
</td>
</tr>
<tr>
<td>
<p><code>none</code></p>
</td>
<td>
<p><code>/:categories/:title:output_ext</code></p>
</td>
</tr>
{%- endfor %}
</tbody>
</table>
</div>
@ -381,57 +132,12 @@ Collections have the following placeholders available:
</tr>
</thead>
<tbody>
{%- for entry in site.data.permalinks.types.documents -%}
<tr>
<td>
<p><code>:collection</code></p>
</td>
<td>
<p>Label of the containing collection.</p>
</td>
</tr>
<tr>
<td>
<p><code>:path</code></p>
</td>
<td>
<p>
Path to the document relative to the collection's directory,
including base filename of the document.
</p>
</td>
</tr>
<tr>
<td>
<p><code>:name</code></p>
</td>
<td>
<p>The document's base filename, with every sequence of spaces
and non-alphanumeric characters replaced by a hyphen.</p>
</td>
</tr>
<tr>
<td>
<p><code>:title</code></p>
</td>
<td>
<p>
The <code>:title</code> template variable will take the
<code>slug</code> <a href="/docs/front-matter/">front matter</a>
variable value if any is present in the document; if none is
defined then <code>:title</code> will be equivalent to
<code>:name</code>, aka the slug generated from the filename.
Preserves case from the source.
</p>
</td>
</tr>
<tr>
<td>
<p><code>:output_ext</code></p>
</td>
<td>
<p>Extension of the output file. (Included by default and usually unnecessary.)</p>
</td>
<td><p><code>:{{ entry.name }}</code></p></td>
<td><p>{{ entry.desc }}</p></td>
</tr>
{%- endfor -%}
</tbody>
</table>
</div>
@ -453,36 +159,12 @@ Pages have the following placeholders available:
</tr>
</thead>
<tbody>
{%- for entry in site.data.permalinks.types.pages -%}
<tr>
<td>
<p><code>:path</code></p>
</td>
<td>
<p>
Path to the page relative to the site's source directory, excluding
base filename of the page.
</p>
</td>
</tr>
<tr>
<td>
<p><code>:basename</code></p>
</td>
<td>
<p>The page's base filename</p>
</td>
</tr>
<tr>
<td>
<p><code>:output_ext</code></p>
</td>
<td>
<p>
Extension of the output file. (Included by default and usually
unnecessary.)
</p>
</td>
<td><p><code>:{{ entry.name }}</code></p></td>
<td><p>{{ entry.desc }}</p></td>
</tr>
{%- endfor -%}
</tbody>
</table>
</div>