-
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
Convert amp example to TypeScript #37744
Convert amp example to TypeScript #37744
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I re-added the usage of styled-jsx
here instead of the _document
as that's the default we recommend for AMP but looks good other than that, thanks for the PR!
Thanks @ijjk! However, it appears your re-adding the usage of styled-jsx prevents the example from building.
If styled-jsx is the recommended default, I'd to figure out the correct usage to put this discussion to rest: #16755 |
@maxproske that was due to a bug on stable which is fixed in the latest canary of Next.js |
@ijjk I updated and encounter the same error on |
@ijjk You're completely right, it works! I was still on v12.1.7-canary.10. Thanks for making contributing to Next.js fun! 😄 |
Converted AMP First Boilerplate example over to TypeScript to match the Contribution guidelines. Note: Requires `v12.1.7-canary.41` or newer to build #37744 (comment) ## Documentation / Examples - [X] Make sure the linting passes by running `pnpm lint` - [X] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
Converted AMP Story example over to TypeScript to align with the Examples guide. Note: Requires `v12.1.7-canary.41` or newer to build #37744 (comment) ## Documentation / Examples - [X] Make sure the linting passes by running `pnpm lint` - [X] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
Converted AMP example over to TypeScript to match the Contribution guidelines, updated all dependencies, and made some necessary changes to allow AMP apps to build in TypeScript.
I added an additional .d.ts file, and referenced it in the tsconfig.json include array, as per the Next.js docs. These additional types are required to allow lowercase AMP elements to be a property on JSX.IntrinsicElements.
Fixes:
I also replaced all occurrences of styled JSX with @ijjk's workaround to get styles in the head at build time for AMP-only pages, hybrid AMP pages, and normal pages (non-AMP).
I tried using the useAmp hook first with multiple
<style jsx>
like this Next.js discussion, however AMP expects a single<style amp-custom>
tag in the head.Fixes:
Documentation / Examples
pnpm lint