-
Notifications
You must be signed in to change notification settings - Fork 26.7k
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
Duplicate amp-custom #7584
Comments
Hi, you can add custom styles using a custom Example: import Document from 'next/document'
export default class MyDocument extends Document {
static async getInitialProps (ctx) {
const initialProps = await Document.getInitialProps(ctx)
return {
...initialProps,
styles: (
<>
{initialProps.styles}
<style dangerouslySetInnerHTML={{
__html: `body{ background: orange; }`
}} />
</>
)
}
}
} If you are still having trouble with this feel free to reply with additional info. |
@ijjk what if I just want to use styles on some page (only on AMP page, for example)? |
AMP feature in next.js is not working. I have tried below source code : import 'isomorphic-fetch' import { useAmp } from 'next/amp' const app = ({ stars }) => ( dddddddddddddssssssssssssssssssssss First Post |
This is still a problem when using amp within
which will render the styles but the validator is still seeing an empty amp-custom style tag. |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
Describe the bug
I was working on Next.js with Netlify CMS by using withAmp().
I add
<style amp-custom>
inNext Head
but because of usingwithAmp()
which (likely to) auto generate<style amp-custom>
with blank style.The result is duplication of using <style amp-custom> which will failed if used AMP validator.
I try searching around about adding CSS to withAmp and changing the 'auto added' amp-custom style but result was no luck, plus I can't seem to find a proper way to fix this and documentation about using withAmp properly (which is not on 'learn' and blog post) like: second parameter options of withAmp, does it only include
{ hybrid: true }
?I can't seem to find a good documentation of
withAmp
and can't add<style amp-custom>
To Reproduce
yarn dev
and go tolocalhost:3000
, you should see there's two<style amp-custom="">
, one contains style, one doesn'tyarn export
, build failed as a result of failed AMP Validator from duplication of<style amp-custom>
Expected behavior
Is there a way to reduce
<style amp-custom>
to one, like adding a config to remove 'auto added'<style amp-custom>
or add style to 'auto added'<style amp-custom>
.Screenshots
System information
Tried on Chrome and Firefox.
Additional context
Add any other context about the problem here.
Is there a clear documentation of using AMP with CSS or using AMP or just example using similar to this?
The text was updated successfully, but these errors were encountered: