带有 React 的 Google AMP [英] Google AMP with React

查看:22
本文介绍了带有 React 的 Google AMP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个同构的反应应用程序与节点.我想将一些页面转换为 AMP 页面.我很迷惑!我们应该使用该应用程序的单独 AMP 版本,还是应根据 Google AMP 页面指南修改当前应用程序?我可以看到我们必须在当前的应用程序中进行大量更改才能制作与放大器兼容的版本.我应该如何进行?

We have an isomorphic react App with node. I want to convert some pages to AMP pages. I am confused! Shall we go for a separate AMP version of the app or shall we modify the current app according to Google guidelines for AMP Pages? I can see we have to make a lot of changes in the current app to make an amp compatible version. How should I proceed?

推荐答案

Next.js 现在支持 AMP.他们提供了多种方法(仅 AMP 和 AMP 混合)来解决这个问题.由于您可以在页面级别启用 AMP,因此您可以慢慢迁移到完整的 AMP 网站.

Next.js now supports AMP. They provide multiple approaches (AMP-only & AMP-hybrid) to solve this problem. Since you can enable AMP on page level you can slowly migrate to a full AMP website.

示例

// pages/about.js
export const config = { amp: true }

export default function AboutPage(props) {
  return <h3>My AMP About Page!</h3>
}

这样您就可以同时支持两者.React 客户端渲染和纯 AMP.

This way you can support both. React client rendering and pure AMP.

Docs Next.js AMP

这篇关于带有 React 的 Google AMP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆