AMP

Important: this documentation is not applicable to your currently selected format websites!

amp-story-page-outlink

Description

A CTA button for opening external links with one tap in AMP story pages.

 

Required Scripts

<script async custom-element="amp-story" src="https://cdn.ampproject.org/v0/amp-story-1.0.js"></script>

Usage

amp-story-page-outlink provide a UI for a one-tap outlink experience. The outlink can be opened by users through a "swipe up" gesture, or a tap on the call to action element. A UI button prompting the viewer to open the attachment will appear at the bottom of every page with a amp-story-page-outlink element. It must have the layout="nodisplay" attribute.

amp-story-page-outlink requires a single a element child.


<amp-story-page id="page-outlink-example">
  <amp-story-grid-layer template="fill">
    <amp-img src="https://example.ampproject.org/helloworld/bg1.jpg" width="900" height="1600">
  </amp-story-grid-layer>
  <amp-story-page-outlink layout="nodisplay">
    <a href="https://www.google.com" title="Link Description"></a>
  </amp-story-page-outlink>
</amp-story-page>

Placement

The <amp-story-page-outlink> element must be the last child of <amp-story-page>, and must have the layout="nodisplay" attribute.

Both amp-story-page-outlink and amp-story-page-attachment must be the last child tag of an amp-story-page. Because of this, you may include neither or one, but not both.

Attributes

When no attributes are set, the default UI will render:

amp-story-page-outlink-default

<amp-story-page-outlink layout="nodisplay">
    <a href="https://www.google.com"></a>
</amp-story-page-outlink>

cta-text (optional)

String that customizes the button text. The default is "Swipe up".

amp-story-page-outlink-cta-text

<amp-story-page-outlink
  layout="nodisplay"
  cta-text="Read More">
  ...
</amp-story-page-outlink>

theme (optional)

String representing the color theme, default is light. Accepts values light, dark, and custom.

theme="custom" requires two additional attributes:

  • `cta-accent-color`: String that represents the custom theme’s color.
  • `cta-accent-element`: String that represents the element to apply the custom theme to. Accepts values `text` and `background`.

Contrast protection is automatically applied to ensure readability and a11y compliance. For example, when the accent element is "background", the higher contrast color (black or white) is applied to the text.

amp-story-page-outlink-dark-theme

<amp-story-page-outlink
  layout="nodisplay"
  theme="dark">
    <a href="https://www.google.com">Call To Action</a>
</amp-story-page-outlink>

amp-story-page-outlink-custom-theme

<amp-story-page-outlink
  layout="nodisplay"
  theme="custom"
  cta-accent-element="background"
  cta-accent-color="#0047FF">
    <a href="https://www.google.com">Call To Action</a>
</amp-story-page-outlink>

amp-story-page-outlink-custom-theme

<amp-story-page-outlink
  layout="nodisplay"
  theme="custom"
  cta-accent-element="text"
  cta-accent-color="#247C3C">
    <a href="https://www.google.com">Call To Action</a>
</amp-story-page-outlink>

cta-image (optional)

String representing a URL pointing to an image. Optimize performance and avoid distortion by using a 32x32px image. A link icon will be displayed by default.

amp-story-page-outlink-cta-image

<amp-story-page-outlink
  layout="nodisplay"
  cta-image="/static/images/32x32icon.jpg">
    <a href="https://www.google.com">Call To Action</a>
</amp-story-page-outlink>

Specifying cta-image=none will remove the default link icon.

amp-story-page-outlink-cta-image-none

<amp-story-page-outlink
  layout="nodisplay"
  cta-image="none">
    <a href="https://www.google.com">Call To Action</a>
</amp-story-page-outlink>

The functionality of amp-story-page-outlink used to be supported by amp-story-page-attachment. Please use amp-story-page-outlink for one-tap outlinking UI.

Bạn cần được trợ giúp thêm?

Bạn đã đọc tài liệu này hàng chục lần, nhưng nó không thật sự trả lời mọi thắc mắc của bạn? Có lẽ những người khác cũng cảm thấy như vậy: hãy liên hệ với họ trên Stack Overflow.

Truy cập Stack Overflow
Bạn tìm thấy một lỗi hoặc cần bổ sung một tính năng?

Dự án AMP đặc biệt khuyến khích sự tham gia và đóng góp của bạn! Chúng tôi hi vọng bạn sẽ trở thành một người tham gia tích cực trong cộng đồng mã nguồn mở của chúng tôi, nhưng chúng tôi cũng chào mừng các đóng góp đơn lẻ về vấn đề mà bạn đặc biệt quan tâm.

Truy cập GitHub