{"id":20766745,"url":"https://github.com/chapter-three/simple_amp","last_synced_at":"2025-06-23T08:40:21.390Z","repository":{"id":141089140,"uuid":"96592309","full_name":"chapter-three/simple_amp","owner":"chapter-three","description":"Simple AMP integration Drupal 8 module","archived":false,"fork":false,"pushed_at":"2017-12-14T07:03:17.000Z","size":45,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-01-18T06:27:34.528Z","etag":null,"topics":["amp","drupal-8","module"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chapter-three.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-08T03:04:55.000Z","updated_at":"2017-08-27T06:49:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"f2e17367-4db7-4f62-bcbe-5183da0dd834","html_url":"https://github.com/chapter-three/simple_amp","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chapter-three%2Fsimple_amp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chapter-three%2Fsimple_amp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chapter-three%2Fsimple_amp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chapter-three%2Fsimple_amp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chapter-three","download_url":"https://codeload.github.com/chapter-three/simple_amp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243094247,"owners_count":20235478,"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","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":["amp","drupal-8","module"],"created_at":"2024-11-17T11:25:55.401Z","updated_at":"2025-03-11T18:50:12.108Z","avatar_url":"https://github.com/chapter-three.png","language":"PHP","readme":"# Simple AMP (Accelerated Mobile Pages) integration Drupal 8 module\n\nModule requires `composer require lullabot/amp` [https://github.com/Lullabot/amp-library](https://github.com/Lullabot/amp-library)\n\nThe module is extendable, there are two components: AmpComponent and AmpMetadata.\n\nRead blog post about this module: [How to implement simple AMP support in Drupal 8](https://www.chapterthree.com/blog/how-implement-simple-amp-support-drupal-8)\n\nThis module has been released on Drupal.org, see [Simple AMP](https://goo.gl/UNR6m4) project page.\n\n## How to Use\n\n- Create new `Display Mode` for your entity that will support AMP. New View modes can be created via `/admin/structure/display-modes/view`.\n- Enable newly created View mode on entity `Manage Display` page. Example path: `/admin/structure/types/manage/article/display`\n- Open Simple AMP Entity Types page and enable entity type that supports AMP and choose `Display Mode` for it. `/admin/config/services/simple-amp`.\n- Open Components settings page and enable default components. `/admin/config/services/simple-amp/components`.\n- Hit `Save configuration` and you're all set.\n\n## URL alias\n\nIf you would like to have URL alias in the path /node-alias/amp instead of /node/[nid]/amp please install [Sub-pathauto (Sub-path URL Aliases)](https://www.drupal.org/project/subpathauto)\n\n## Theming\n\n- Modify template in `simple_amp/templates/amp.html.twig` to match your design \n- You may also have custom template per content type: `amp--node.html.twig` or `amp--node--article.html.twig`\n\n## Plugins\n\n### AmpComponent\n\nAll plugins stored in src/Plugin/AmpComponent/* currently the module doesn't support all available AMP components, but can be easily extended from your own module.\n\nHere is example:\n\nThe key variables here are:\n\n- name - plugin name\n- description - plugin description.\n- regexp - array of regular expressions to match in HTML body.\n\n```\n\u003c?php\n\nnamespace Drupal\\simple_amp\\Plugin\\AmpComponent;\n\nuse Drupal\\simple_amp\\AmpComponentBase;\n\n/**\n * Youtube AMP component.\n *\n * @AmpComponent(\n *   id = \"amp-youtube\",\n *   name = @Translation(\"YouTube\"),\n *   description = @Translation(\"YouTube Component\"),\n *   regexp = {\n *     \"/\u003camp\\-youtube.*\u003e\u003c\\/amp\\-youtube\u003e/isU\",\n *   }\n * )\n */\nclass Youtube extends AmpComponentBase {\n\n  /**\n   * {@inheritdoc}\n   */\n  public function getElement() {\n    return '\u003cscript async custom-element=\"amp-youtube\" src=\"https://cdn.ampproject.org/v0/amp-youtube-0.1.js\"\u003e\u003c/script\u003e';\n  }\n\n}\n```\n\n### AmpMetadata\n\nAll plugins stored in src/Plugin/AmpMetadata/* provide Metadata for specific entity.\n\nHere is example:\n\nThe key variables here are:\n\n- entity_types - array of entity type names. This will tell the module to generate AMP Metadata for entity types specified in this variable.\n\n```\n\u003c?php\n\nnamespace Drupal\\simple_amp\\Plugin\\AmpMetadata;\n\nuse Drupal\\simple_amp\\AmpMetadataBase;\nuse Drupal\\simple_amp\\Metadata\\Metadata;\nuse Drupal\\simple_amp\\Metadata\\Author;\nuse Drupal\\simple_amp\\Metadata\\Publisher;\nuse Drupal\\simple_amp\\Metadata\\Image;\n\n/**\n * Example AMP metadata component.\n *\n * @AmpMetadata(\n *   id = \"default\",\n *   entity_types = {\n *     \"example_article\"\n *   }\n * )\n */\nclass ExampleEntity extends AmpMetadataBase {\n\n  /**\n   * {@inheritdoc}\n   */\n  public function getMetadata($entity) {\n    $metadata = new Metadata();\n    $author = (new Author())\n      -\u003esetName('Test Author');\n    $logo = (new Image())\n      -\u003esetUrl('http://url-to-image')\n      -\u003esetWidth(400)\n      -\u003esetHeight(300);\n    $publisher = (new Publisher())\n      -\u003esetName('MyWebsite.com')\n      -\u003esetLogo($logo);\n    $image = (new Image())\n      -\u003esetUrl('http://url-to-image')\n      -\u003esetWidth(400)\n      -\u003esetHeight(300);\n    $metadata\n      -\u003esetDatePublished($entity-\u003egetCreatedTime())\n      -\u003esetDateModified($entity-\u003egetChangedTime())\n      -\u003esetDescription('test')\n      -\u003esetAuthor($author)\n      -\u003esetPublisher($publisher)\n      -\u003esetImage($image);\n    return $metadata-\u003ebuild();\n  }\n\n}\n```\n\nModule developed by [Minnur Yunusov](https://www.minnur.com) at [Chapter Three](https://www.chapterthree.com)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchapter-three%2Fsimple_amp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchapter-three%2Fsimple_amp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchapter-three%2Fsimple_amp/lists"}