{"_id":"@armada-inc/gatsby-plugin-amp","_rev":"1-fd2a0a17a53679b64cf9563cfbf81c96","name":"@armada-inc/gatsby-plugin-amp","dist-tags":{"latest":"0.2.3"},"versions":{"0.2.3":{"name":"@armada-inc/gatsby-plugin-amp","version":"0.2.3","description":"A gatsby plugin for scaffolding AMP pages","main":"index.js","scripts":{"build":"babel src --out-dir . --ignore **/__tests__","prepare":"npm run build","watch":"babel -w src --out-dir . --ignore **/__tests__","commit":"git add . && git commit && git push -u origin master"},"author":{"name":"Armada Intelligence Inc"},"license":"MIT","homepage":"https://github.com/armada-inc/gatsby-plugin-amp#readme","repository":{"type":"git","url":"git+https://github.com/armada-inc/gatsby-plugin-amp.git"},"bugs":{"url":"https://github.com/armada-inc/gatsby-plugin-amp/issues"},"dependencies":{"jsdom":"^13.0.0","lodash.flattendeep":"^4.4.0","minimatch":"^3.0.4","react":"^16.6.1"},"keywords":["gatsby","gatsby-plugin","gatsby-plugin-amp","amp","accelerated-mobile-pages"],"devDependencies":{"babel-preset-gatsby-package":"^0.1.2","@babel/cli":"^7.1.5","@babel/core":"^7.1.5"},"gitHead":"56f37e93ded695e6a42d33840a20d49471915dd1","_id":"@armada-inc/gatsby-plugin-amp@0.2.3","_nodeVersion":"12.13.1","_npmVersion":"6.12.1","dist":{"integrity":"sha512-UuZkWSM7Kzvk8Zuu8+hmLpfNm9e7DMfTm1WYr6qWssOvQpxmFm3VNjIdJPrlBo4II7cmeMw11z4z+gNkKF9d6A==","shasum":"27b0796dd2851644238e45b4ab03ef74e4bcaa46","tarball":"https://registry.npmjs.org/@armada-inc/gatsby-plugin-amp/-/gatsby-plugin-amp-0.2.3.tgz","fileCount":5,"unpackedSize":23522,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJecxyJCRA9TVsSAnZWagAA7J8QAIji3vAjfmWsfPENsiue\nS0Vdy7EMnYMdTZw+7w9kX8gO/lOpEEQ/ztmamtj3IHL6Tw2Lnihn/Dmb8osj\nqFLUxBeF9kw2rf9kWdPP/bSyp+ZejrGkfBsBZWKWSs6ltMdgF/sNkLZGvIxT\nAZVGNMqzLWrNbYkW8x8puWTFBUW46r/f94nfTifMTvQflbUr4VUAnS/+1Uku\nR193momHlLAgzNLyMxPfBVhc4XOWth6mhwnjRVAtMNg3gxHgNU5QasmOGC+s\ne0c0BUOFRordnL5YwrMkES3r6IUZfyj9R3uptjs46pxDG4FH4JPnNCxCuce7\n1USq4/EpIiHOVKZC3TEJRPx6Z9khTXarMfxdUWCcM1Bh//sZ3rSKio7VKeM4\nOyKfMIWI5fVycyqJXocpeF8IZc3q6gtX7WLO8N/MaHoLD6PV4yj8tDCnl++U\nHBHx55T+tJYkvFPF2QylDeTltZxLphH1smWHDT2UtK1sBisy+C74a5U3DDFE\nG5JMvhUHRaHwbodt7YBnec3H+qZj4A4+RGM9zBgw5yCVG3Oz+IwLfcehEPcp\nImHyIMAqnBolJUeehaPhxzzcq+njpSsw7vNvHLv7MShgEDtJQa1iohEDQznB\nm8GtJTk6Go4qPcZckXy1le2yy9SJbyYKGXQJRakKW5wg5WVR9xMcOQ7+MclX\nyki4\r\n=lMqE\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDt0EqjhLXOQJJIsjwvMjSgEAd1pmU/4tzAvz/gUPLR5wIhAM2TZ8Hru7W53yG2Qo+3/iBewQCiaPrEU9lYlbpcL1WL"}]},"maintainers":[{"name":"thanda_anda","email":"keyur.raval18@gmail.com"},{"name":"shyamlohar","email":"shyamlohar1996@gmail.com"},{"name":"keyurarmada","email":"keyur@getarmada.app"}],"_npmUser":{"name":"shyamlohar","email":"shyamlohar1996@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gatsby-plugin-amp_0.2.3_1584602249031_0.9408095956992679"},"_hasShrinkwrap":false}},"time":{"created":"2020-03-19T07:17:28.798Z","0.2.3":"2020-03-19T07:17:29.208Z","modified":"2022-04-04T15:32:44.543Z"},"maintainers":[{"name":"thanda_anda","email":"keyur.raval18@gmail.com"},{"name":"shyamlohar","email":"shyamlohar1996@gmail.com"},{"name":"keyurarmada","email":"keyur@getarmada.app"}],"description":"A gatsby plugin for scaffolding AMP pages","homepage":"https://github.com/armada-inc/gatsby-plugin-amp#readme","keywords":["gatsby","gatsby-plugin","gatsby-plugin-amp","amp","accelerated-mobile-pages"],"repository":{"type":"git","url":"git+https://github.com/armada-inc/gatsby-plugin-amp.git"},"author":{"name":"Armada Intelligence Inc"},"bugs":{"url":"https://github.com/armada-inc/gatsby-plugin-amp/issues"},"license":"MIT","readme":"# gatsby-plugin-amp\r\n\r\nFormats AMP-specific pages by removing javascript, combining styles and adding boilerplate. Read more about AMP (Accelerated Mobile Pages) [here](https://amp.dev/).\r\n\r\n## Install\r\n\r\n`npm install --save gatsby-plugin-amp`\r\n\r\n## How to use\r\n\r\nCreate AMP-specific templates. Assume you have the following blog post template in `post.js`\r\n\r\n```javascript\r\nimport React from 'react'\r\nimport Img from 'gatsby-image'\r\nimport Layout from '../../components/layout'\r\n\r\nexport default ({ data }) => (\r\n  <Layout>\r\n    <Img fluid={data.image.fluid} />\r\n    <h1>REGULAR PAGE</h1>\r\n    <p>regular page content</p>\r\n  </Layout>\r\n)\r\n```\r\n\r\nCreate an AMP template `post.amp.js`\r\n\r\n```javascript\r\nimport React from 'react'\r\nimport Layout from '../../components/layout'\r\n\r\nexport default ({ data }) => (\r\n  <Layout>\r\n    <amp-img src-set={data.image.srcSet} src={data.image.src} width={data.image.width} height={data.image.height} alt={data.image.altText} layout=\"responsive\" />\r\n    <h1>AMP PAGE</h1>\r\n    <p>amp page content</p>\r\n  </Layout>\r\n)\r\n```\r\n\r\nTo assist with situations like images in markdown or other externally created HTML, the plugin will attempt to turn `img` tags to `amp-img` or `amp-anim`. While creating posts in your `gatsby-node.js` file, create an additional page in the `/amp/` directory using the AMP template you just made\r\n\r\n```javascript\r\n_.each(posts, (post, index) => {\r\n  const previous = index === posts.length - 1 ? null : posts[index + 1].node;\r\n  const next = index === 0 ? null : posts[index - 1].node;\r\n\r\n  createPage({\r\n    path: post.node.fields.slug,\r\n    component: path.resolve('./src/templates/post.js'),\r\n    context: {\r\n      slug: post.node.fields.slug,\r\n      previous,\r\n      next,\r\n    },\r\n  })\r\n\r\n  createPage({\r\n    path: `${post.node.fields.slug}/amp`,\r\n    component: path.resolve('./src/templates/post.amp.js'),\r\n    context: {\r\n      slug: post.node.fields.slug,\r\n      previous,\r\n      next,\r\n    },\r\n  })\r\n})\r\n```\r\n\r\nWhen you build your site, you should now have pages at `/my-awesome-post/index.html` and `/my-awesome-post/amp/index.html`\r\n\r\nAdd the plugin to the plugins array in your `gatsby-config.js`\r\n\r\n```javascript\r\n{\r\n  resolve: `gatsby-plugin-amp`,\r\n  options: {\r\n    analytics: {\r\n      type: 'gtag',\r\n      dataCredentials: 'include',\r\n      config: {\r\n        vars: {\r\n          gtag_id: <GA_TRACKING_ID>,\r\n          config: {\r\n            <GA_TRACKING_ID>: {\r\n              page_location: '{{pathname}}'\r\n            },\r\n          },\r\n        },\r\n      },\r\n    },\r\n    canonicalBaseUrl: 'http://www.example.com/',\r\n    components: ['amp-form'],\r\n    excludedPaths: ['/404*', '/'],\r\n    pathIdentifier: '/amp/',\r\n    relAmpHtmlPattern: '{{canonicalBaseUrl}}{{pathname}}{{pathIdentifier}}',\r\n    useAmpClientIdApi: true,\r\n  },\r\n},\r\n```\r\n\r\nWhen your site builds, your page in the `/amp` directory should now be a valid AMP page\r\n\r\n## Options\r\n\r\n**analytics** `{Object}`\r\nIf you want to include any `amp-analytics` tags, set that configuration here.\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;**type** `{String}`\r\n&nbsp;&nbsp;&nbsp;&nbsp;Your analytics type. See the list of available vendors [here](https://www.ampproject.org/docs/analytics/analytics-vendors).\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;**dataCredentials** `{String}`\r\n&nbsp;&nbsp;&nbsp;&nbsp;You value for the `data-credentials` attribute. Omit to remove the attribute.\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;**config** `{Object | String}`\r\n&nbsp;&nbsp;&nbsp;&nbsp;This can be either an object containing your analytics configuration or a url to your analytics configuration. If you use Google Analytics gtag, your cofiguration might look like this:\r\n\r\n```javascript\r\nvars: {\r\n  gtag_id: <GA_TRACKING_ID>,\r\n  config: {\r\n    <GA_TRACKING_ID>: {\r\n      page_location: '{{pathname}}'\r\n    },\r\n  },\r\n},\r\n```\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp; If you use a tag manager, your config would simply be a url like `https://www.googletagmanager.com/amp.json?id=GTM-1234567&amp;gtm.url=SOURCE_URL`. You can use double curly braces to interpolate the pathname into a configuration value e.g. `page_location: '{{pathname}}'`. See [here](https://www.ampproject.org/docs/reference/components/amp-analytics) to learn more about `amp-analytics` configurations.\r\n\r\n**canonicalBaseUrl** `{String}`\r\nThe base URL for your site. This will be used to create a `rel=\"canonical\"` link in your amp template and `rel=\"amphtml\"` link in your base page.\r\n\r\n**components** `{Array<String | Object{name<String>, version<String>}>}`\r\nThe components you will need for your AMP templates. Read more about the available components [here](https://www.ampproject.org/docs/reference/components).\r\n\r\n**excludedPaths**`{Array<String>}`\r\nBy default, this plugin will create `rel=\"amphtml\"` links in all pages. If there are pages you would like to not have those links, include them here. You may use glob patterns in your strings (e.g. `/admin/*`). *this may go away if a way can be found to programatically exclude pages based on whether or not they have an AMP equivalent. But for now, this will work*\r\n\r\n**includedPaths**`{Array<String>}`\r\nBy default, this plugin will create `rel=\"amphtml\"` links in all pages. If, you would instead like to whitelist pages, include them here. You may use glob patterns in your strings (e.g. `/blog/*`). *this may go away if a way can be found to programatically exclude pages based on whether or not they have an AMP equivalent. But for now, this will work*\r\n\r\n**pathIdentifier** `{String}`\r\nThe url segment which identifies AMP pages. If your regular page is at `http://www.example.com/blog/my-awesome-post` and your AMP page is at `http://www.example.com/blog/my-awesome-post/amp/`, your pathIdentifier should be `/amp/`\r\n\r\n**relAmpHtmlPattern** `{String}`\r\nThe url pattern for your `rel=\"amphtml\"` links. If your AMP pages follow the pattern `http://www.example.com/my-awesome-post/amp/`, the value for this should be `{{canonicalBaseUrl}}{{pathname}}{{pathIdentifier}}`.\r\n\r\n**relCanonicalPattern** `{String}`\r\nThe url pattern for your `rel=\"canonical\"` links. The default value is `{{canonicalBaseUrl}}{{pathname}}`.\r\n\r\n**useAmpClientIdApi** `{Boolean}`\r\nIf you are using a Client ID for Google Analytics, you can use the [Google AMP Client ID](https://support.google.com/analytics/answer/7486764) to determine if events belong to the same user when they visit your site on AMP and non-AMP pages. Set this to `true` if you would like to include the necessary meta tag in your AMP pages. You can read more about this concept [here](https://www.simoahava.com/analytics/accelerated-mobile-pages-via-google-tag-manager/#2-1-client-id)\r\n\r\n## Caveats\r\n\r\nThe standard HTML template that Gatsby uses will cause a validation error. This is because it is missing `minimum-scale=1` in the meta viewport tag. You can create a `html.js` template file under your `src/` directory in order to override the default Gatsby one available [here](https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/cache-dir/default-html.js). Alternatively, you can simply clone it by runnig the shell command below at the root of your project. Read more [here](https://www.gatsbyjs.org/docs/custom-html/) on customizing your `html.js`.\r\n\r\n```shell\r\ncp .cache/default-html.js src/html.js\r\n```\r\n\r\nDon't forget to update the meta viewport tag value from its initial to the required AMP value.\r\n\r\n```html\r\n<!-- Initial viewport meta tag -->\r\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\" />\r\n<!-- Replacement viewport meta tag (for AMP validity) -->\r\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, minimum-scale=1, shrink-to-fit=no\" />\r\n```\r\n\r\n## Automatically Converted Elements\r\n\r\nWhile it is preferable to create AMP-specific templates, there may be situations where an image, iframe or some other element can't be modified. To cover these cases, the plugin will attempt to convert certain tags to their AMP equivalent.\r\n\r\n| HTML Tag       | AMP Tag           | Status                     | Issue |\r\n|----------------|-------------------|----------------------------|-------|\r\n| `img`          | `amp-img`         | Completed                  |       |\r\n| `img (.gif)`   | `amp-anim`        | Completed                  |       |\r\n| `iframe`       | `amp-iframe`      | Completed                  |       |\r\n| `audio`        | `amp-audio`       | Planned, Not Started       |       |\r\n| `video`        | `amp-video`       | Planned, Not Started       |       |\r\n| YouTube        | `amp-youtube`     | Completed                  |       |\r\n| Facebook       | `amp-facebook`    | Planned, Not Started       |       |\r\n| Instagram      | `amp-instagram`   | Planned, Not Started       |       |\r\n| Twitter        | `amp-twitter`     | Completed                  |       |\r\n","readmeFilename":"README.md"}