Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions _layouts/latest-quickstarts.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
layout: default
---
<!-- _layouts/latest-quickstarts.html -->
{%- assign version = site.data.kroxylicious.latestRelease -%}
{%- assign underscored_version = version | replace: '.', '_' -%}
<div class="row align-items-start justify-content-center my-5">
<div class="col-lg-6" role="main">
<div class="row row-cols-1 row-cols-md-2 g-4">
{%- assign docs_for_release = site.data.documentation[underscored_version].docs | sort: "rank" -%}
{%- for doc in docs_for_release -%}
{%- if doc.path contains 'quick' -%}
{%- assign first1 = doc.path | slice: 0, 1 -%}
{%- assign first7 = doc.path | slice: 0, 7 -%}
{%- assign first8 = doc.path | slice: 0, 8 -%}
{%- if first7 == 'http://' or first8 == 'https://' -%}
{%- assign linkTemplate = doc.path -%}
{%- elsif first1 == '/' -%}
{%- assign linkTemplate = doc.path | absolute_url -%}
{%- else -%}
{%- assign linkTemplate = "/documentation/" | append: version | append: "/" | append: doc.path | absolute_url -%}
{%- endif -%}
Comment on lines +13 to +22
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole section is a little confusing to follow, I think we can simplify it a little (tested this locally and it looks like it works fine).

Suggested change
{%- assign first1 = doc.path | slice: 0, 1 -%}
{%- assign first7 = doc.path | slice: 0, 7 -%}
{%- assign first8 = doc.path | slice: 0, 8 -%}
{%- if first7 == 'http://' or first8 == 'https://' -%}
{%- assign linkTemplate = doc.path -%}
{%- elsif first1 == '/' -%}
{%- assign linkTemplate = doc.path | absolute_url -%}
{%- else -%}
{%- assign linkTemplate = "/documentation/" | append: version | append: "/" | append: doc.path | absolute_url -%}
{%- endif -%}
{%- assign isFullURL = doc.path | split:'http' | first -%}
{%- assign hasSlashPrefix = doc.path | split:'/' | first -%}
{%- if isFullURL == empty -%}
{%- assign linkTemplate = doc.path -%}
{%- elsif hasSlashPrefix == empty -%}
{%- assign linkTemplate = doc.path | absolute_url -%}
{%- else -%}
{%- assign linkTemplate = "/documentation/" | append: version | append: "/" | append: doc.path | absolute_url -%}
{%- endif -%}

Unfortunately Liquid doesn't let us assign boolean values to variables from expressions, but we can get the same behaviour by splitting on the value we want to check if the string starts with, and then seeing if the first item in the resulting array (i.e. any characters that preceded the split) is an empty string. If the string just contained the value we were looking for but didn't start with it, then the first index won't be an empty string.

Could also be worth adding some comments to indicate what's going on here:

Suggested change
{%- assign first1 = doc.path | slice: 0, 1 -%}
{%- assign first7 = doc.path | slice: 0, 7 -%}
{%- assign first8 = doc.path | slice: 0, 8 -%}
{%- if first7 == 'http://' or first8 == 'https://' -%}
{%- assign linkTemplate = doc.path -%}
{%- elsif first1 == '/' -%}
{%- assign linkTemplate = doc.path | absolute_url -%}
{%- else -%}
{%- assign linkTemplate = "/documentation/" | append: version | append: "/" | append: doc.path | absolute_url -%}
{%- endif -%}
<!-- check if doc.path is full URL (i.e. starts with 'http') -->
{%- assign isFullURL = doc.path | split:'http' | first -%}
<!-- check if doc.path is a partial URI with a slash prefix (i.e. starts with a '/') -->
{%- assign hasSlashPrefix = doc.path | split:'/' | first -%}
<!-- begin conditional assign -->
{%- if isFullURL == empty -%}
<!-- is full URL -->
{%- assign linkTemplate = doc.path -%}
{%- elsif hasSlashPrefix == empty -%}
<!-- partial URI with slash prefix -->
{%- assign linkTemplate = doc.path | absolute_url -%}
{%- else -%}
<!-- is other partial URI not beginning with '/' -->
{%- assign linkTemplate = "/documentation/" | append: version | append: "/" | append: doc.path | absolute_url -%}
{%- endif -%}
<!-- end conditional assign -->

<div class="col">
<div class="card shadow mb-2 h-100 mx-2 {%- for tag in doc.tags %} doctag-{{tag}}{%- endfor -%}">
<div class="card-header">
<h2 class="card-title fs-4"><a href='{{ linkTemplate | replace: "$(VERSION)", version}}'>{{ doc.title }}</a></h2>
</div>
<div class="card-body mx-3 my-2">
{{ doc.description }}
</div>
</div>
</div>
{%- endif -%}
{%- endfor -%}
</div>
</div>
</div>

3 changes: 3 additions & 0 deletions quickstarts/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
layout: latest-quickstarts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I see that we've still got that old _layouts/quickstart.html layout file from the old quickstarts hanging around and that's likely to cause some confusion here. The old file is only being used for the proxy and developer quickstarts for docs versions 0.13.0 and below, so maybe we could change that layout file to be called something like legacy-docs-quickstart.html and then this could just be quickstart.html.

related nit: I don't like calling it quickstarts with an 's', I think if the aim is to have a quick link then it makes a little more sense to just call it quickstart (which is actually what I thought it was at first, and got a little confused when it gave me a 404 back).

---