-
Notifications
You must be signed in to change notification settings - Fork 182
[Feat] Updated the Wordpress Tutorial page in the Layer5 Docs #1047
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: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,74 +15,51 @@ In this tutorial, we will learn how to embed a **Meshery Design** in a WordPress | |||||
|
|
||||||
| This tutorial assumes that you have created a design or have an existing one. If not, you can use one of the numerous public designs available in **Kanvas** for this tutorial. | ||||||
|
|
||||||
| 1. Expand the **Designs** menu on the left. | ||||||
| 1. Expand the **Actions** menu on the left and select export. | ||||||
|
|
||||||
|  | ||||||
|
|
||||||
| 2. Click the **Quick actions** button to the left of the design (inverted ellipsis) and select **Export Design**. | ||||||
| 2. Click the download icon next to **Embed Design**. | ||||||
|
|
||||||
|  | ||||||
|
|
||||||
| 3. Click the download icon next to **Embed Design** from the list. | ||||||
|
|
||||||
|  | ||||||
|
|
||||||
| 4. This will show the `js` file to download and the HTML code snipped to copy. | ||||||
| 3. This will show the `js` file to download and the HTML code snipped to copy. | ||||||
|
|
||||||
|  | ||||||
|
|
||||||
| 5. Now, head over to WordPress and begin by uploading the `js` file to it. Ideally you will upload it to Media. | ||||||
|
|
||||||
|  | ||||||
| 4. Now, create a `js` folder in the path of your current wordpress theme | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
|
|
||||||
| 6. Next, click on the uploaded file in WordPress and copy the File URL. You will need this later. | ||||||
| 5. Next, copy the downloaded `js` file into this folder. | ||||||
|
|
||||||
|  | ||||||
|  | ||||||
|
|
||||||
| 6. To the following script, replace `design_file_name.js` with the name of the `js` file which you just downloaded. Once this is done, go to the `functions.php` file in your current Wordpress theme and copy script. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor grammatical improvement ("copy the script"), capitalization fix for "WordPress", and removal of an extra space after the comma.
Suggested change
|
||||||
|
|
||||||
| ``` | ||||||
| function kanvas_design_script() { | ||||||
| $script_uri = get_template_directory_uri() . design_file_name.js'; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The PHP code snippet contains a syntax error (missing opening quote) and the path should include the /js/ directory created in step 4 to match the instructions.
Suggested change
|
||||||
| wp_enqueue_script_module( | ||||||
| 'kanvas-design', | ||||||
| $script_uri, | ||||||
| array(), | ||||||
| '1.1.0', | ||||||
| ); | ||||||
| } | ||||||
| add_action('wp_enqueue_scripts', 'kanvas_design_script'); | ||||||
| ``` | ||||||
|
|
||||||
|  | ||||||
|
|
||||||
| 7. Open the WordPress post where you want to embed the design in edit mode and add a _Custom HTML_ block. | ||||||
|
|
||||||
|  | ||||||
|
|
||||||
| 8. Paste the following CSS code as it is, followed by the **Embed Code** copied from **Kanvas**. Update the script source value to the URL copied from WordPress. | ||||||
| ``` | ||||||
| <style> | ||||||
| .embed-design-container { | ||||||
| width: 100%; | ||||||
| border-radius: 1rem; | ||||||
| margin: 1rem; | ||||||
| overflow: hidden; | ||||||
| margin-inline: auto; | ||||||
| height: 35rem; | ||||||
| } | ||||||
| .embed-canvas-container { | ||||||
| background-color: gray; | ||||||
| } | ||||||
| </style> | ||||||
| ``` | ||||||
| The final _Custom HTML_ should look something like this: | ||||||
| ``` | ||||||
| <style> | ||||||
| .embed-design-container { | ||||||
| width: 100%; | ||||||
| border-radius: 1rem; | ||||||
| margin: 1rem; | ||||||
| overflow: hidden; | ||||||
| margin-inline: auto; | ||||||
| height: 35rem; | ||||||
| } | ||||||
| .embed-canvas-container { | ||||||
| background-color: gray; | ||||||
| } | ||||||
| </style> | ||||||
| <!-- Learn more at https://docs.layer5.io/meshmap/designer/export-designs/#exporting-as-embedding --> | ||||||
| <div id="embedded-design-a1376b51-d2c4-4ef8-8337-6dc2c24fa939"></div> | ||||||
| <script src="https://yourwordpressdomain/wp-content/uploads/2025/01/embedded-design-tutorial-exploring-kubernetes-pod.js" type="module" ></script> | ||||||
| ``` | ||||||
|  | ||||||
| 8. Paste the **Embed Code** copied from **Kanvas**. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the script is already being enqueued via functions.php in Step 6, the user only needs to paste the element from the Embed Code. Including the <script> tag again is redundant and may lead to duplicate script loading.
Suggested change
|
||||||
|
|
||||||
|  | ||||||
|
|
||||||
| 9. Click **Preview** to validate that the design is rendered. | ||||||
|
|
||||||
|  | ||||||
|
|
||||||
| 10. Publish the WordPress post and share. | ||||||
|
|
||||||
| 10. Publish the WordPress post and share. | ||||||
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.
Typo: "snipped" should be "snippet".