Skip to content

Commit 458ec46

Browse files
committed
Update readme by migrating hot to use section from ampproject/amp-wp#1519
1 parent 138fe0d commit 458ec46

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

README.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,42 @@
33
Add support for app shell navigation via AMP Shadow DOM.
44

55
This is a WordPress plugin which you can activate to see the app shell navigation
6-
in action. It extends the functionality of the [AMP plugin](https://github.com/ampproject/amp-wp).
6+
in action. It extends the functionality of the [AMP plugin](https://wordpress.org/plugins/amp/).
77

88
Tha app shell navigation based on AMP Shadow DOM is an experimental feature initially
99
proposed in [ampproject/amp-wp#1519](https://github.com/ampproject/amp-wp/pull/1519).
1010

1111
In order for the plugin to work, you will have to install the
12-
[AMP](https://github.com/ampproject/amp-wp) and [PWA](https://wordpress.org/plugins/pwa/) plugins.
12+
[AMP](https://wordpress.org/plugins/amp/) and [PWA](https://wordpress.org/plugins/pwa/) plugins.
1313

1414
Note that you will also have to run `composer install && npm install && npm run build`
1515
prior to activating the plugin.
16+
17+
## How To Use
18+
19+
For a theme to support app shell via the AMP plugin, the bare minimum that needs to be done is:
20+
21+
1. Activate on [AMP](https://wordpress.org/plugins/amp/) and [PWA](https://wordpress.org/plugins/pwa/) plugins.
22+
2. Ensure your theme (and plugins) work entirely in the AMP plugin's [Transitional mode](https://amp-wp.org/documentation/how-the-plugin-works/amp-plugin-serving-strategies/). You must use Transitional mode as opposed to Standard mode for now. Make sure that you have “Serve all templates as AMP regardless of what is being queried” enabled.
23+
3. Identify the element that contains the markup that changes as you navigate from page to page and wrap it with two function calls to indicate where the app shell container is:
24+
```php
25+
<?php amp_start_app_shell_content(); ?>
26+
<?php get_template_part( 'content' ); ?>
27+
<?php amp_end_app_shell_content(); ?>
28+
```
29+
4. Opt-in to AMP theme support for app shell by adding the following to your `functions.php`:
30+
```php
31+
add_theme_support( 'amp', array(
32+
'paired' => true,
33+
'app_shell' => true,
34+
) );
35+
```
36+
5. You should define an `offline.php` template in your theme.
37+
38+
For theme which adds support for AMP app shell see https://github.com/xwp/twentyseventeen-westonson. Note that this theme copies some code from the Twenty Seventeen parent theme in order to add make the necessary modifications. For example, the `js/global.js` file modified as per [this diff](https://gist.github.com/westonruter/b9d7952c0879ea3cda9e0081e387846d). The theme has app shell behind a theme mod flag, so make sure you do `wp theme mod set service_worker_navigation amp_app_shell` via WP-CLI. See also how it [adds skeleton content](https://github.com/xwp/twentyseventeen-westonson/blob/03934b7328f9b18dd979ae97458ad38feb6f0e1a/functions.php#L241-L283) to the app shell. See also plugin to [enable stale-while-revalidate caching strategy for navigation requests](https://gist.github.com/westonruter/f848013108672568be6dcde153f9ca37).
39+
40+
This was presented at CDS 2018; see [related portion of talk](https://youtu.be/s1WrBaAyzAI?t=940).
41+
42+
See also this short screen cast: https://youtu.be/oAiIbhHdoXM
43+
44+
For some more background on this, see [GoogleChromeLabs/pwa-wp#12 (comment)](https://github.com/GoogleChromeLabs/pwa-wp/issues/12#issuecomment-401843173)

0 commit comments

Comments
 (0)