如何在我的网站中嵌入AMP页面?

时间:2017-05-15 19:11:26

标签: javascript amp-html

我正在使用网络应用来汇总新闻。我想在与移动设备上显示的谷歌搜索结果相同的窗口中显示已启用放大器的页面。

我还没有找到关于如何在我们的网站上嵌入放大器页面的单一文档。

我尝试了这两个链接 -

PolyerLab - 这个没有加载页面,因为chrome禁用了CORS,所以无法进一步测试它(我不知道它是否忽略了google.com的CORS限制?)

AMP by Example - 来自官方ampproject网站的查看者,`viewer.html'所需的文件amp-viewer-host.max.jsviewer-integr-messaging.js git存储库中缺少。

对于stackoverflow也没有问题。有没有人实现过这样的东西?非常感谢!

2 个答案:

答案 0 :(得分:3)

example in the official repository是开始实施自己的AMP查看器的最佳方式。当build the AMP runtime locally时,您会获得amp-viewer-host.max.js。运行dist/v0/examples/amp-viewer-host.max.js后,它位于:gulp build。不再需要其他文件viewer-integr-messaging.js

答案 1 :(得分:0)

您可以访问包含amphtml& amp;的实际网站页面。放大器页面的URL。只需在iframe中加载该网址即可。 例如:
网站页面:

 www.example.com/product_page it has <link rel="amphtml" href="www.example.com/product_page_amp-version.html"> in its <head>
to embed use 
<iframe src="www.example.com/product_page_amp-version.html"></iframe>