Upgrade to Pro — share decks privately, control downloads, hide ads and more …

amp

ararajp
February 02, 2017

 amp

ararajp

February 02, 2017
Tweet

More Decks by ararajp

Other Decks in Technology

Transcript

  1. routing ௨ৗϖʔδͷURLʹ/ampΛ෇͚଍ͨ͠αϒςΟϨΫτϦํࣜ https://item.iqon.jp/15011036 // ௨ৗϖʔδ https://item.iqon.jp/15011036/amp // AMPϖʔδ get '/:item_id/amp',

    to: 'item#amp', constraints: {item_id: /[0-9]+/} ?amp=1 / .ampͰ൑அͳͲαʔϏε͝ͱʹ౎߹͕ྑ͍ͷʹ͠·͠ΐ͏ αϒυϝΠϯͰ΋͍͚·͢
  2. Controller PC/ϞόΠϧͱڞ௨ͷॲཧͰcanonical͚ͩઃఆ AMP༻ͷviewͱlayoutͰϨϯμϦϯά def amp if _detail # PC/ϞόΠϧͳͲͱڞ௨ͷॲཧ @html[:canonical]

    = "https://item.iqon.jp/#{@item[:item_id]}/" # ϞόΠϧϖʔδ΁canonical render 'item/amp/detail', layout: 'amp/layout' # AMP༻ͷৄࡉϖʔδͱϨΠΞ΢τ end end def sp @html[:amphtml] = "https:#{domain_item}/#{@item[:item_id]}/amp/" if params[:amp].blank? end
  3. View ෆཁͳίϯϙʔωϯτͷJSΛಡΈࠐΉͱܯࠂ͕ग़Δ JSͷಡΈࠐΈॱ΋ݫີʹܾ·͍ͬͯΔ layout # ڞ௨ͷAMP JS͸layoutͰಡΈࠐΉ script async=true custom-element="amp-analytics"

    src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js" = yield(:extended_component_tags) script async=true src='https://cdn.ampproject.org/v0.js' Template content_for :extended_component_tags do script async=true custom-element="amp-carousel" src="https://cdn.ampproject.org/v0/amp-carousel-0.1.js"