-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first stab at html for applies to yaml frontmatter
- Loading branch information
Showing
6 changed files
with
185 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
title: Product Availability | ||
applies: | ||
stack: ga 8.1 | ||
serverless: tech-preview | ||
hosted: beta 8.1.1 | ||
eck: beta 3.0.2 | ||
ece: unavailable | ||
--- | ||
|
||
|
||
Using yaml frontmatter pages can explicitly indicate to each deployment targets availability and lifecycle status | ||
|
||
|
||
```yaml | ||
applies: | ||
stack: ga 8.1 | ||
serverless: tech-preview | ||
hosted: beta 8.1.1 | ||
eck: beta 3.0.2 | ||
ece: unavailable | ||
``` | ||
Its syntax is | ||
``` | ||
<product>: <lifecycle> [version] | ||
``` | ||
Where version is optional. | ||
`all` and empty string mean generally available for all active versions | ||
|
||
```yaml | ||
applies: | ||
stack: | ||
serverless: all | ||
``` | ||
|
||
`all` and empty string can also be specified at a version level | ||
|
||
```yaml | ||
applies: | ||
stack: beta all | ||
serverless: beta | ||
``` | ||
|
||
Are equivalent, note `all` just means we won't be rendering the version portion in the html. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
@using Elastic.Markdown.Myst.FrontMatter | ||
@inherits RazorSlice<Elastic.Markdown.Myst.FrontMatter.Deployment> | ||
<p class="product-availability"> | ||
<span class="applies-to-label sd-badge sd-outline-transparent sd-text-black"> | ||
Applies To: | ||
</span> | ||
@if (Model.SelfManaged is not null) | ||
{ | ||
if (Model.SelfManaged.Stack is not null) | ||
{ | ||
@RenderProduct("Elastic Stack", Model.SelfManaged.Stack) | ||
} | ||
if (Model.SelfManaged.Ece is not null) | ||
{ | ||
@RenderProduct("Elastic Cloud Enterprise", Model.SelfManaged.Ece) | ||
} | ||
if (Model.SelfManaged.Eck is not null) | ||
{ | ||
@RenderProduct("Elastic Cloud Kubernetes", Model.SelfManaged.Eck) | ||
} | ||
} | ||
@if (Model.Cloud is not null) | ||
{ | ||
if (Model.Cloud.Hosted is not null) | ||
{ | ||
@RenderProduct("Elastic Cloud Hosted", Model.Cloud.Hosted) | ||
} | ||
if (Model.Cloud.Serverless is not null) | ||
{ | ||
@RenderProduct("Serverless", Model.Cloud.Serverless) | ||
} | ||
} | ||
</p> | ||
|
||
@functions { | ||
|
||
private string GetLifeCycleClass(ProductLifecycle cycle) | ||
{ | ||
switch (cycle) | ||
{ | ||
case ProductLifecycle.Deprecated: | ||
case ProductLifecycle.Coming: | ||
case ProductLifecycle.Discontinued: | ||
case ProductLifecycle.Unavailable: | ||
return "muted"; | ||
case ProductLifecycle.GenerallyAvailable: | ||
case ProductLifecycle.TechnicalPreview: | ||
case ProductLifecycle.Beta: | ||
case ProductLifecycle.Development: | ||
return "primary"; | ||
default: | ||
throw new ArgumentOutOfRangeException(nameof(cycle), cycle, null); | ||
} | ||
} | ||
private string GetLifeCycleName(ProductLifecycle cycle) | ||
{ | ||
switch (cycle) | ||
{ | ||
case ProductLifecycle.TechnicalPreview: | ||
return "Technical Preview"; | ||
case ProductLifecycle.Beta: | ||
return "Beta"; | ||
case ProductLifecycle.Development: | ||
return "Development"; | ||
case ProductLifecycle.Deprecated: | ||
return "Deprecated"; | ||
case ProductLifecycle.Coming: | ||
return "Coming"; | ||
case ProductLifecycle.Discontinued: | ||
return "Discontinued"; | ||
case ProductLifecycle.Unavailable: | ||
return "Unavailable"; | ||
case ProductLifecycle.GenerallyAvailable: | ||
return "GA"; | ||
default: | ||
throw new ArgumentOutOfRangeException(nameof(cycle), cycle, null); | ||
} | ||
} | ||
|
||
private IHtmlContent RenderProduct(string name, ProductAvailability product) | ||
{ | ||
var c = GetLifeCycleClass(product.Lifecycle); | ||
<span class="sd-badge sd-outline-@c sd-text-@c applies-badge"> | ||
@name | ||
@if (product.Lifecycle != ProductLifecycle.GenerallyAvailable) | ||
{ | ||
<span class="sd-text-secondary">@GetLifeCycleName(product.Lifecycle)</span> | ||
} | ||
@if (product.Version is not null and not AllVersions) | ||
{ | ||
<span class="sd-text-success">(@product.Version)</span> | ||
} | ||
</span> | ||
return HtmlString.Empty; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters