AMP HTML⚡ Bundle - provide AMP HTML conversion to your SilverStripe website.
- lullabot/amp ^1.1.3
- silverstripe/framework 4+
Install with composer
composer require silverstripers/amp dev-master
To clear the amp caches you need to set up an RSA Key.
Follow the instructions on the AMP Cache guide on Generating Keys.
To set up the private key use the following YAML configutation
SilverStripers\AMP\Control\AMPCache:
key_file: 'PATH_TO_YOUR_PRIVATE_KEY'
The module allows you to set up class name of pages which are supported by AMPs.
---
Name: amps
---
SilverStripers\AMP\Control\AMPDirector:
allowed_classes:
- SilverStripe\Blog\Model\Blog
- SilverStripe\Blog\Model\BlogPost
The configs above limits the amps support to Blog and BlogPost pages.
This module adds extensions on for your controllers where the pages will have an AMP based version with a URL suffix for each page.
EG:
/home/ will have /home/amp.html /about-us/ will have /about-us/amp.html
The mobile also provides a template global $IsAMP
which you can use on any template to add specific HTML segments for the AMP version of the website.
The module adds cannonical URLs and amphtml links for the sites as well.
In order to determine whether the current request is in AMP or not you can use $IsAMP
variable.
<% if $IsAMP %>
<!-- YOUR AMP CODES HERE -->
<% end_if %>
Same way you can use the not as well
<% if not $IsAMP %>
<!-- YOUR NONE AMP CODES HERE -->
<% end_if %>
The module supports elemental module.
If you are having to override the templates for Elemental objects you can have templates with _AMP suffix, when those templates are found the elements gets rendered using those.
Please create an issue for any bugs, or submit merge requests.