generated from layer5io/layer5-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #419 from layer5io/embed-shortcode
Add Design Embed shortcode and docs
- Loading branch information
Showing
2 changed files
with
133 additions
and
24 deletions.
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
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,60 @@ | ||
<!-- | ||
This shortcode is used to embed a Meshery design into hugo sites | ||
Meshery Design Embedding allows exporting a design as an interactive component | ||
that integrates seamlessly into websites, blogs, or any platform supporting HTML, CSS, and JavaScript. | ||
This embedded design is interactive, making it easier for infrastructure stakeholders | ||
to visualize, explore, and collaborate on service mesh designs. | ||
-- Usage: | ||
{{/*< meshery-design-embed src="path/to/embed.js" id="unique-id" style="custom-styles" >*/}} | ||
More Information: | ||
Learn more about embedding Meshery designs at: | ||
https://docs.layer5.io/kanvas/designer/embedding-designs/ | ||
--> | ||
|
||
<!-- | ||
Retrieve the path to the JavaScript file generated for embedding the Meshery design. | ||
This script is generated when exporting a design from kanvas.new. | ||
The `src` attribute specifies the script location, as provided by the user. | ||
--> | ||
{{ $script := .Get "src" }} | ||
|
||
<!-- | ||
Retrieve the unique ID for the embedded Meshery design. | ||
This ID is typically generated when creating the embed code and is used to uniquely | ||
identify the container for the embedded design on the page. | ||
--> | ||
{{ $id := .Get "id" }} | ||
|
||
<!-- | ||
Retrieve optional custom styles for the embedding container. | ||
If not provided, a default style will be applied to ensure proper rendering. | ||
--> | ||
{{ $style := .Get "style" }} | ||
|
||
<!-- | ||
Embedding Container: | ||
A `div` element is dynamically created with the provided or default styles. | ||
- The `id` attribute links to the unique design embed. | ||
- The `style` attribute can be customized or fall back to a default appearance, | ||
which includes: | ||
- Height: 30rem | ||
- Width: 100% (responsive to container width) | ||
- Border: 1px solid #eee (light border for visibility) | ||
--> | ||
<div | ||
id="{{ $id }}" | ||
{{ if $style }} | ||
style="{{ $style }}" | ||
{{ else }} | ||
style="height: 30rem; width: 100%; border: 1px solid #eee" | ||
{{ end }} | ||
></div> | ||
|
||
<!-- | ||
Embed Script: | ||
The JavaScript file (retrieved from the `src` attribute) is included here. | ||
- The `type="module"` ensures the script runs in a modern ES6 module context. | ||
--> | ||
<script src="{{ $script }}" type="module"></script> |