Open In App

Google AMP amp-facebook-like

Improve
Improve
Like Article
Like
Save
Share
Report

Introduction: A really popular featured in web pages are like button from social media platforms. The amp-facebook-like is used to embed a Facebook like button to an AMP HTML page. Here when a Facebook like button is embedded you can like the post without going to Facebook itself.

Required Script: Add the following script containing source to importing the amp-facebook-like component.

HTML




<script async custom-element="amp-facebook-like" src=
</script>


Attributes:

  1. data-href: URL of the page to be liked.
  2. data-action: String to be displayed on button. Default value is “Like”.
  3. data-colorscheme: Color scheme that should be used outside the button. By default, it is light and it can be kept as dark also.
  4. data-size: It is used to change the size of the button. By default, it is small and it can be set to large also.
  5. data-layout : It is used to change the layout of the button. There are four layouts available and these are:
    • standard (Default)
    • button
    • button_count
    • box_count

Example:

HTML




<!doctype html>
<html amp>
  
<head>
    <meta charset="utf-8">
    <title>amp-facebook-like</title>
    <script async src=
    </script>
  
    <!-- Import the `amp-facebook-like` 
        component to add a like button-->
    <script async custom-element=
            "amp-facebook-like" src=
    </script>
  
    <link rel="canonical" href=
    <meta name="viewport" content=
"width=device-width,minimum-scale=1,initial-scale=1">
    <style amp-boilerplate>
        body {
            -webkit-animation: -amp-start 8s 
                    steps(1, end) 0s 1 normal both;
            -moz-animation: -amp-start 8s 
                    steps(1, end) 0s 1 normal both;
            -ms-animation: -amp-start 8s 
                    steps(1, end) 0s 1 normal both;
            animation: -amp-start 8s 
                    steps(1, end) 0s 1 normal both
        }
  
        @-webkit-keyframes -amp-start {
            from {
                visibility: hidden
            }
  
            to {
                visibility: visible
            }
        }
  
        @-moz-keyframes -amp-start {
            from {
                visibility: hidden
            }
  
            to {
                visibility: visible
            }
        }
  
        @-ms-keyframes -amp-start {
            from {
                visibility: hidden
            }
  
            to {
                visibility: visible
            }
        }
  
        @-o-keyframes -amp-start {
            from {
                visibility: hidden
            }
  
            to {
                visibility: visible
            }
        }
  
        @keyframes -amp-start {
            from {
                visibility: hidden
            }
  
            to {
                visibility: visible
            }
        }
    </style>
    <noscript>
        <style amp-boilerplate>
            body {
                -webkit-animation: none;
                -moz-animation: none;
                -ms-animation: none;
                animation: none
            }
        </style>
    </noscript>
</head>
  
<body>
    <amp-facebook-like width="100" height="30"
        layout="fixed" data-layout="button_count"
        data-href=
    </amp-facebook-like>
</body>
  
</html>


Output



Last Updated : 16 Oct, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads