-
Notifications
You must be signed in to change notification settings - Fork 26.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
with-amp example is not pass AMP Validator #3155
Comments
There are two problems:
To remove the Add a In this file you should extend // _head.js
import { Head } from 'next/document'
export default class MyHead extends Head {
getChunkPreloadLink (filename) {
// remove as='script' in return statement
}
getPreloadDynamicChunks () {
// remove as='script' in return statement
}
render () {
// in return statement remove as='script' from <link rel='preload'... lines
}
}
// you should redeclare this function because is not exported
function getPagePathname (pathname, nextExport) {
if (!nextExport) return pathname
if (pathname === '/') return '/index.js'
return `${pathname}/index.js`
}
Finally, you should change // _document.js
import Head from './_head' The AMP validation is successful but you get a warning:
Here is a discussion about this warning from the AMP Project repo. This is the solution that I've found, probably it's not the best, and it should be reviewed 😉. Related: #2310 |
Thanks so much @ismamz Another problem I am facing is using
can we combine all css to |
You can add the However, there are some problems: 1) styled-jsx will add class names to custom amp tags and it's not valid, 2) you are intervening the way of work of styled-jsx. So, maybe styled-jsx is not the best option for an AMP site in this case. |
I'm going to close this as we're going to make some changes to better support AMP soon. |
@timneutkens thanks for the update. Looking forward to AMP changes soon. We have AMP templates and trying to migrate those to Next soon. |
@timneutkens Great! we hope to receive news soon about an excellent integration of AMP with NextJs 😃 |
Any news on AMP support here? |
@ismamz I'm currently working on AMP with ReactJs, is there a way to have custom attributes in square brackets such as [class] with reactJs on client side as well. As of now, reactJs when re-render all the custom attributes gets eliminated. |
@varungargofb Hi!, I think that this is not a Next.js related question. <div dangerouslySetInnerHTML={{__html: '<p [text]="\'Hello \' + foo">Hello World</p>'}}/>
<button on="tap:AMP.setState({foo: 'amp-bind'})">Say "Hello amp-bind"</button> Other ways like using I hope that helps you. |
Because of AMP restriction, it does not allow custom script,
But the server rendering include custom script of next.js, so
with-amp
example is not pass AMP Validator.Can we remove those scripts ?
Thank you.
The text was updated successfully, but these errors were encountered: