Download next.js/packages/next/src/build/babel/plugins/amp-attributes.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 754 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/build/babel/plugins/amp-attributes.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/next/src/build/babel/plugins/amp-attributes.ts
-
curl -L -o amp-attributes.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/build/babel/plugins/amp-attributes.ts
754 Bytes
| import type { NodePath, types, PluginObj } from 'next/dist/compiled/babel/core' | |
| export default function AmpAttributePatcher(): PluginObj { | |
| return { | |
| visitor: { | |
| JSXOpeningElement(path: NodePath<types.JSXOpeningElement>) { | |
| const openingElement = path.node | |
| const { name, attributes } = openingElement | |
| if (!(name && name.type === 'JSXIdentifier')) { | |
| return | |
| } | |
| if (!name.name.startsWith('amp-')) { | |
| return | |
| } | |
| for (const attribute of attributes) { | |
| if (attribute.type !== 'JSXAttribute') { | |
| continue | |
| } | |
| if (attribute.name.name === 'className') { | |
| attribute.name.name = 'class' | |
| } | |
| } | |
| }, | |
| }, | |
| } | |
| } | |