Extension for the static-site generator Grow that auto injects <script> tags for used AMP components.
This is a Grow PostRenderHook. After rendering the full page it searches the generated markup for hints of used AMP components. This is done by simple string lookups and though may break for markup inside of <code>
blocks. This is work in progress.
After matching the found dependencies against a list of valid dependencies they get injected by creating a DOM of the rendered document and injecting <script>
tags matching the dependencies into the document.
- Create an
extensions.txt
file within your pod. - Add to the file:
git+git://github.com/jungvonmatt/grow-ext-amp-dependency-injector
- Run
grow install
. - Add the following section to
podspec.yaml
:
ext:
- extensions.amp_dependency_injector.AmpDependencyInjectorExtension
By default all pages that have a HTML tag of either <html amp
or <html ⚡
are considered AMP pages and get their dependencies injected. To opt out of this behaviour for a specific page set the following inside the document's frontmatter:
$$injectAmpDependencies: False