You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/static-web-apps/snippets.md
+17-5Lines changed: 17 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,14 +11,19 @@ ms.author: cshoe
11
11
12
12
# Snippets in Azure Static Web Apps (preview)
13
13
14
-
Azure Static Web Apps allows you to inject custom code into the `head` or `body` elements at runtime. These pieces of code are known as "snippets".
14
+
Azure Static Web Apps allows you to inject custom code into the `head` or `body` elements at runtime. These pieces of code are known as *snippets*.
15
+
16
+
Snippets give you the flexibility to add code to every page in your site in a single place, all without modifying the core codebase.
15
17
16
18
Common use cases of snippets include:
17
19
18
20
- Analytics scripts
19
21
- Common scripts
20
22
- Global UI elements
21
23
24
+
> [!NOTE]
25
+
> Some front-end frameworks may overwrite your snippet code. Test your snippets before applying them to a production environment.
26
+
22
27
## Add a snippet
23
28
24
29
1. Go to your static web app in the Azure portal.
@@ -27,17 +32,24 @@ Common use cases of snippets include:
27
32
28
33
1. Select the **Snippets** tab.
29
34
35
+
1. Select the **Add** button.
36
+
30
37
1. Enter the following settings in the Snippets window:
31
38
32
39
| Setting | Value | Comments |
33
-
|---|---|--|
34
-
| Location | Select which element as the destination for your code. ||
40
+
|---|---|---|
41
+
| Location | Select which HTML page element you want your code injected into. ||
35
42
| Name | Enter a snippet name. ||
36
-
| Insertion location | Select whether you want to **Prepend** or **Append** your code to the selected element. | Prepend means your code appears directly after the open tag of the element. Append means your code appears directly before the close tag of the element. |
37
-
| Environment | Select the environment(s) you want to target. | If you select**Select environment** then you can choose a selection of environments to target. |
43
+
| Insertion location | Select whether you want to **Prepend** or **Append** your code to the selected element. |*Prepend* means your code appears directly after the open tag of the element. *Append* means your code appears directly before the close tag of the element. |
44
+
| Environment | Select the environment(s) you want to target. | If you pick**Select environment**, then you can choose from different environments to target. |
0 commit comments