Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Don't remove boilerplate for amp-stories #850

Merged
merged 1 commit into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/optimizer/lib/Extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ module.exports = {
return false;
}
const extension = script.attribs['custom-element'];
return extension === 'amp-dynamic-css-classes' || extension === 'amp-experiment';
return (
extension === 'amp-dynamic-css-classes' ||
extension === 'amp-experiment' ||
extension === 'amp-story'
);
},
isCustomElement: function (node) {
return node.tagName && node.tagName.startsWith('amp-');
Expand Down
5 changes: 4 additions & 1 deletion packages/optimizer/lib/transformers/ServerSideRendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ class ServerSideRendering {
continue;
}
if (isRenderDelayingExtension(node)) {
this.log_.debug('cannot remove boilerplate: amp-dynamic-css-classes');
this.log_.debug(
'cannot remove boilerplate because of a render delaying extension: ',
node.tagName
);
canRemoveBoilerplate = false;
}
if (hasAttribute(node, 'amp-custom')) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!doctype html>
<html amp lang="en" i-amphtml-layout>
<head><style amp-runtime></style>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-story" src="https://cdn.ampproject.org/v0/amp-story-1.0.js"></script>
<title>My Story</title>
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<link rel="canonical" href="helloworld.html">
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<style amp-custom>
body {
font-family: 'Roboto', sans-serif;
}
amp-story-page {
background: white;
}
h1 {
font-size: 2.875em;
font-weight: normal;
line-height: 1.174;
text-transform: uppercase;
}
</style>
</head>

<body>
<amp-story standalone class="i-amphtml-layout-container" i-amphtml-layout="container">

<amp-story-page id="cover" class="i-amphtml-layout-container" i-amphtml-layout="container">
<amp-story-grid-layer template="vertical" class="i-amphtml-layout-container" i-amphtml-layout="container">
<h1>Hello World</h1>
<p>This is the cover page of this story.</p>
</amp-story-grid-layer>
</amp-story-page>

<amp-story-page id="page-1" class="i-amphtml-layout-container" i-amphtml-layout="container">
<amp-story-grid-layer template="vertical" class="i-amphtml-layout-container" i-amphtml-layout="container">
<h1>First Page</h1>
<p>This is the first page of this story.</p>
</amp-story-grid-layer>
</amp-story-page>

<amp-story-page id="page-2" class="i-amphtml-layout-container" i-amphtml-layout="container">
<amp-story-grid-layer template="vertical" class="i-amphtml-layout-container" i-amphtml-layout="container">
<h1>Second Page</h1>
<p>This is the second page of this story.</p>
</amp-story-grid-layer>
</amp-story-page>
</amp-story>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!doctype html>
<html amp lang="en">
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-story"
src="https://cdn.ampproject.org/v0/amp-story-1.0.js"></script>
<title>My Story</title>
<meta name="viewport"
content="width=device-width,minimum-scale=1,initial-scale=1">
<link rel="canonical" href="helloworld.html">
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<style amp-custom>
body {
font-family: 'Roboto', sans-serif;
}
amp-story-page {
background: white;
}
h1 {
font-size: 2.875em;
font-weight: normal;
line-height: 1.174;
text-transform: uppercase;
}
</style>
</head>

<body>
<amp-story standalone>

<amp-story-page id="cover">
<amp-story-grid-layer template="vertical">
<h1>Hello World</h1>
<p>This is the cover page of this story.</p>
</amp-story-grid-layer>
</amp-story-page>

<amp-story-page id="page-1">
<amp-story-grid-layer template="vertical">
<h1>First Page</h1>
<p>This is the first page of this story.</p>
</amp-story-grid-layer>
</amp-story-page>

<amp-story-page id="page-2">
<amp-story-grid-layer template="vertical">
<h1>Second Page</h1>
<p>This is the second page of this story.</p>
</amp-story-grid-layer>
</amp-story-page>
</amp-story>
</body>
</html>