{"id":24383543,"url":"https://github.com/firstandthird/hapi-amp","last_synced_at":"2025-12-27T10:07:30.452Z","repository":{"id":53726360,"uuid":"78824032","full_name":"firstandthird/hapi-amp","owner":"firstandthird","description":null,"archived":false,"fork":false,"pushed_at":"2021-03-17T18:30:26.000Z","size":21,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-12T17:23:26.262Z","etag":null,"topics":["hapi-plugin"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/firstandthird.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-13T06:59:09.000Z","updated_at":"2021-03-17T18:30:26.000Z","dependencies_parsed_at":"2022-09-13T08:11:14.030Z","dependency_job_id":null,"html_url":"https://github.com/firstandthird/hapi-amp","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/firstandthird/hapi-amp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstandthird%2Fhapi-amp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstandthird%2Fhapi-amp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstandthird%2Fhapi-amp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstandthird%2Fhapi-amp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/firstandthird","download_url":"https://codeload.github.com/firstandthird/hapi-amp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstandthird%2Fhapi-amp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28077395,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-27T02:00:05.897Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hapi-plugin"],"created_at":"2025-01-19T10:14:44.552Z","updated_at":"2025-12-27T10:07:30.432Z","avatar_url":"https://github.com/firstandthird.png","language":"JavaScript","readme":"# hapi-amp\n\n[![Build Status](https://travis-ci.org/firstandthird/hapi-amp.svg?branch=master)](https://travis-ci.org/firstandthird/hapi-amp)\n[![Coverage Status](https://coveralls.io/repos/github/firstandthird/hapi-amp/badge.svg?branch=master)](https://coveralls.io/github/firstandthird/hapi-amp?branch=master)\n\nA simple [hapi](https://hapi.dev/) plugin that automates switching to an Accelerated Mobile Page (AMP) version of your view.\n\n## Install\n\n`npm install hapi-amp`\n\n## Usage\n\nRegister the plugin as you normally would, along with hapi's [vision](https://github.com/hapijs/vision) plugin and your preferred view engine:\n\n```js\n// index.js\nawait server.register(require('vision'));\nawait server.register(require('hapi-amp'));\nserver.views({\n  engines: { html: require('vision-nunjucks') },\n  path: `/views`\n});\n```\n\nIf you use the [Rapptor](https://github.com/firstandthird/rapptor) server framework then you can accomplish the same thing with a configuration file:\n```yaml\n# default.yaml\nplugins:\n  vision:\n  hapi-amp:\nviews:\n  path: '/views'\n  engines:\n    njk: 'vision-nunjucks'\n```\n\nFor each view that you want to provide an AMP version for, just make a corresponding file with `-amp` at the end of the file name:\n\n- /views/homepage.html\n- /views/homepage-amp.html\n- /views/profile.html\n- /views/profile-amp.html\n\nThen you can just render your views like you normally would:\n\n```js\nreturn h.view('pages/homepage');\n```\n\nThe plugin will detect any time a request contains an `?amp=1` query parameter and switch to the `-amp` version of the view if so.  If unable to locate an `-amp` version of your view, it will just fall back to the original view.\n\n\n## Further Features\n\nWhen rendering an AMP page, hapi-amp will also add the following to your view context:\n  - `__isAMP: true `, indicating this is an amp page.\n  - `__AMPOriginal: \u003curl\u003e`, so that your view will still have access to the original _request.url.href_ before the plugin modifies it internally.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirstandthird%2Fhapi-amp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffirstandthird%2Fhapi-amp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirstandthird%2Fhapi-amp/lists"}