Skip to content
This repository was archived by the owner on Jan 27, 2025. It is now read-only.

Commit 12c2e01

Browse files
authored
Update README.md
1 parent 052fbf5 commit 12c2e01

File tree

1 file changed

+45
-14
lines changed

1 file changed

+45
-14
lines changed

README.md

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Visit my newest project Statamictutorials.com. Many tutorials are free.
1111
## Description
1212
A third-party [Laravel Livewire](https://laravel-livewire.com/) integration for Statamic.
1313

14-
It's as easy as it get's to get stared with Livewire if using Statamic.
14+
It's as easy as it gets to get started with Livewire if using Statamic.
1515

1616
## Installation
1717
Pull in the Livewire package with composer
@@ -20,19 +20,32 @@ Pull in the Livewire package with composer
2020
composer require jonassiewertsen/statamic-livewire
2121
```
2222

23-
## Upgrade
24-
25-
Make sure to read the Livewire upgarde guide, in case you're updating to `Statamic Livewire` 3, as there are breaking changes:
26-
https://livewire.laravel.com/docs/upgrading
23+
### Manually including Livewire's frontend assets
24+
By default, Livewire injects the JavaScript and CSS assets it needs into each page that includes a Livewire component. If you want more control over this behavior, you can [manually include the assets](https://livewire.laravel.com/docs/installation#manually-including-livewires-frontend-assets) on a page using the following Antlers tags or Blade directives:
2725

28-
## General documentation
29-
[Livewire Docs](https://livewire.laravel.com/docs/quickstart)
30-
31-
## Livewire scripts and styles
32-
33-
Livewire injects its styles and scripts automatically into the page. However, this does not work if caching is enabled (`half`/`full`). In that case, you want to include them [manually](https://livewire.laravel.com/docs/installation#manually-including-livewires-frontend-assets), by using the respective tags `{{ livewire:styles }}` and`{{ livewire:scripts }}`.
26+
```html
27+
<html>
28+
<head>
29+
<!-- If using Antlers -->
30+
{{ livewire:styles }}
31+
32+
<!-- If using Blade -->
33+
@livewireStyles
34+
</head>
35+
<body>
36+
37+
...
38+
<!-- If using Antlers -->
39+
{{ livewire:scripts }}
40+
41+
<!-- Blade -->
42+
@livewireScripts
43+
</body>
44+
</html>
45+
```
3446

35-
In case you need to include some custom Alpine plugins, you can [bundle the assets yourself](https://livewire.laravel.com/docs/installation#manually-bundling-livewire-and-alpine) and disable the automatic injection by using the `{{ livewire:scriptConfig }}` tag. Do not forget to include the `{{ livewire:styles }}` tag as well.
47+
### Manually bundling Livewire and Alpine
48+
If you need to include some custom Alpine plugins, you need to [manually bundle the Livewire and Alpine assets](https://livewire.laravel.com/docs/installation#manually-bundling-livewire-and-alpine) and disable the automatic injection by using the following Antlers tag or Blade directive. Do not forget to include the Livewire styles as well.
3649

3750
```html
3851
<html>
@@ -47,14 +60,32 @@ In case you need to include some custom Alpine plugins, you can [bundle the asse
4760

4861
...
4962
<!-- If using Antlers -->
50-
{{ livewire:scripts }} / {{ livewire:scriptConfig }}
63+
{{ livewire:scriptConfig }}
5164

5265
<!-- Blade -->
53-
@livewireScripts / @livewireScriptConfig
66+
@livewireScriptConfig
5467
</body>
5568
</html>
5669
```
5770

71+
### Static caching
72+
If you use half or full static caching, add the `LivewireReplacer` to the `replacers` array. Make sure to add this replacer after the `CsrfTokenReplacer` replacer.
73+
74+
```php
75+
'replacers' => [
76+
\Statamic\StaticCaching\Replacers\CsrfTokenReplacer::class,
77+
\Statamic\StaticCaching\Replacers\LivewireReplacer::class,
78+
],
79+
```
80+
81+
## Upgrade
82+
83+
Make sure to read the Livewire upgrade guide, in case you're updating to `Statamic Livewire` 3, as there are breaking changes:
84+
https://livewire.laravel.com/docs/upgrading
85+
86+
## General documentation
87+
[Livewire Docs](https://livewire.laravel.com/docs/quickstart)
88+
5889
### Include components
5990
You can create Livewire components as described in the [general documentation](https://livewire.laravel.com/docs/components).
6091
To include your Livewire component:

0 commit comments

Comments
 (0)