-
Notifications
You must be signed in to change notification settings - Fork 11
Add /quickstarts page to list latest quickstarts #212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
I want to include a link in some video content that will not rot. This link should always contain a list of the quickstarts for the latest version of the proxy. Signed-off-by: Robert Young <robertyoungnz@gmail.com>
e667850 to
dc4280e
Compare
gracegrimwood
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some tweaks and nits.
Also, I think we should add this to the navbar too. Maybe before "Documentation" but after "Download"?
| {%- 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 -%} |
There was a problem hiding this comment.
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).
| {%- 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:
| {%- 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 --> |
| @@ -0,0 +1,3 @@ | |||
| --- | |||
| layout: latest-quickstarts | |||
There was a problem hiding this comment.
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).
I want to include a link in some video content that will not rot. This link should always contain a list of the quickstarts for the latest version of the proxy.