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

制約と誓約

Junya
October 29, 2019

 制約と誓約

Junya

October 29, 2019
Tweet

More Decks by Junya

Other Decks in Programming

Transcript

  1. ࣗݾ঺հ ## Մࣇ ५໵ʢKani Junyaʣ
 - twitterɿ @ka2jun8 ### ܦྺͱॴଐ


    - 2014೥4݄ ৽ଔ F ͔Β͸͡·ΔձࣾʢR&Dʣ
 - 2018೥4݄ த్ R ͔Β͸͡·ΔձࣾʢFEʣ ### ΍ͬͯΔ͜ͱ
 - WebαʔϏεͷ৽ن্ཱͪ͛/ϑϧϦϓϨΠε
 - ࠷ۙ͸ AMP Λ࢖ͬͨ։ൃʹணख ### ϚΠϒʔϜ/޷͖ͳ΋ͷ
 - ೫໦ࡔ46 / Dead by Daylight / HUNTER x HUNTER ←্࢘
  2. AMP is … ༷ʑͳݫ੍͍͠໿ͱ੤໿ͷԼͰ AMP valid ͳWebϖʔδΛ։ൃ ͢Δ͜ͱͰɺGoogle ͷΩϟογϡʹࡌΓɺݕࡧ݁Ռ͔Βߴ଎ʹ WebϖʔδΛදࣔՄೳʹ͢Δɻ

    ੍໿ͱ੤໿ͷྫ
 - JavaScript ͕ར༻Ͱ͖ͳ͍
 - ಈతͳ෦෼͸ AMP ίϯϙʔωϯτΛ࢖͏
 - CSS 50KB ҎԼ
 - ෼ੳ/޿ࠂλά͸ڐ༰͞Εͨ΋ͷͷΈར༻Մೳ
 ͳͲͳͲ…..
  3. Full AMP • ͍͍ͱ͜Ζ
 ˠ ೋॏ։ൃͷඞཁ͕ͳ͍ • ΘΔ͍ͱ͜Ζ
 ˠ AMP

    valid ͷ੍໿ͷԼɺ͢΂ͯͷػೳΛ࡞Γ্͛ Δඞཁ͕͋Δ
  4. next.js + AMP • pages/${hoge}.tsx ϖʔδʹ config Λ export ͢Δ͚ͩ

    • next.js ಺෦ͷ _document.tsx ͳͲͰ amp ༻ʹ html ΛՃ޻ ͯ͘͠ΕΔ https://github.com/zeit/next.js/blob/canary/packages/next/pages/_document.tsx headλά htmlλά
  5. AMP + next.js + styled-components https://github.com/zeit/next.js/blob/canary/examples/with-styled-components/pages/_document.js _document.tsx Ͱ SSR ࣌ʹ

    head λάʹ style Λॻ͖ग़͢ॲཧΛೖΕΔ GlobalStyle ͸ _app.tsx Ͱఆٛ͢Δ ※ͳͥ͜͏ॻ͘ͷ͔͸ɺ಺ ෦ͷॲཧܥ͕݁ߏ΍΍͜͠ ͍ͷͰɺ͜Ε͸·ͨผͰϒ ϩάͱ͔ॻ͔͘΋ AMP ༻ʹ Style Λ 
 <head> ʹશ෦ॻ͘
  6. Styled-components ͱ૬ੑ͕ѱ͍2 • AMP ͸ [class] (data-amp-bind-class) ͱ͍͏ଐੑΛ࣋ͨͤ Δ͜ͱ͕Ͱ͖Δɻ <div

    [class]=“ampState.index==1 ? ‘selected’ : ‘’ ”> • ͜ΕΛ styled-components ʹ͋ͯΔͱ class ͷมߋͱಉ࣌ ʹ style ͕શ෦ॻ͖มΘΔͨΊɺ <StyledDiv [class]=“ampState.index==1 ? ‘selected’ : ‘’> ͱ͍͏;͏ʹ͸ॻ͚ͳ͍ɻ const StyledDiv = styled.div`style: hogehoge;`
  7. AMP analytics / GTM ͕… • Adobe analytics ͷಈ࡞͕ෆ҆ఆ •

    GTM Ͱ AMP ޲͚ͷίϯςφΛ࡞ΕΔ΋ͷ ͷɺಈ࡞อূ͞Εͯͳ͍λά΋ଟ͍ • ͦ΋ͦ΋ AMP cache ʢgoogle υϝΠϯʣ͸ ITP 2.3 Ͱ࠶๚ΛऔΔͷ͸յ໓త…
  8. ͦͷ΄͔ʹ΋ • ϦϦʔε͞Εͳ͍ͱ࣮ࡍͷޮՌ͸Θ͔ΒͣɺAMPʹ͔ͨ͠Βͱ͍ͬͯSEO͕ྑ͘ͳΔอূ͕͋ΔΘ ͚Ͱ͸ͳ͍ɻ • จࣈྻϕʔεͰAMPಠࣗͷଐੑ஋΍onΠϕϯτͷεΫϦϓτΛهड़͢ΔͷͭΒEɻ • amp-sidebar Ͱ iOS

    ͷͱ͖͚ͩ͋Γ͕ͨ໎࿭ͳۭͷ div ΛೖΕͯ͘Δɻ • debugͣ͠Β͍ɻ • AMPΩϟογϡ͕ޮ͍ͯ͠·͏ͱɺApp Indexing͕͖͔ͳ͍ʢΒ͍͠ʣɻ • Chrome ֦ுͷ AMP validator ͕ϦΫΤετΛૹΓ·ͬͯͭ͘Β͍ɻ • next.js Ͱ࢖͍ͬͯΔ amphtml-validator ͷGoogle ຊՈͷ validator ͕ update ͞ΕɺCDNܦ༝Ͱ ഑৴͞Ε͍ͯΔ͜ͱʹΑͬͯ next.js ͕ update ΋ͯ͠ͳ͍ͷʹಥવམͪΔࣄ݅ɻ ͳͲͨ͘͞Μ͋ͬͯॻ͖͖Εͳ͍…
  9. AMP Λ࢖ͬͯ։ൃ͢΂͖͔ʁ • ͋Δఔ౓େن໛ͳاۀͷαʔϏε։ൃΛߦ͏࣮ੈքͰ͸ Full AMP ͸ݫ͍͠ɻ • ҰํɺAMPࣗ਎΍ next.js

    ͕࢖͍΍͘͢ͳΓͭͭ͋ΔʢAMP Bento / next v9ʣɻ AMP ίϯϙʔωϯτ΋ɺWeb Components ͱͯ͠͸࢖͑Δ΋ͷ΋ଟ͍ɻͲͧ͜ ͷ஌Βͳ͍αʔυύʔςΟϥΠϒϥϦΛ࢖͏ΑΓ͸ྑ͍ͱࢥ͏ɻ • AMPΛ࢖͍͍ͨຊ࣭తͳ໨త͸Կཱ͔ͪฦΔɻAMPͱSEO͸௚઀తͳؔ܎ੑ͸ͳ ͍ɻWebϖʔδ͕ߴ଎ʹ͍ͨ͠ͳΒɺύϑΥʔϚϯεόδΣοτ΍lighthouse CI Λ࢖ͬͨύϑΥʔϚϯε୲อͰ΋͍͍͔΋͠Εͳ͍ɻ • GCP, GA ͳͲͷ؀ڥΛ͢΂ͯ Google ʹऔΓғ·Εͨঢ়ଶͰ࡞ΕͯɺAMP cache ͷԸܙ͕ϑϧʹड͚ΒΕΔ؀ڥԼʹ͋ΔͳΒ΍ͬͯ΋͍͍ɻ
  10. ·ͱΊ • AMP ͸ Google ͷ Web ϖʔδߴ଎ԽͷͨΊͷఏҊ • Full

    AMP Ͱ։ൃΛߦ͏ࡍͷ Tips Λগ͠঺հ • AMP ʹ͢Δ΂͖͔Ͳ͏͔͸αʔϏε΍ঢ়گ࣍ୈ • ͨͩɺΈΜͳͰ࢖ͬͯෆຬΛFB͠ɺΤίγεςϜΛ վળ͠ଓ͚͍ͯ͘͜ͱͰະདྷ͸໌Δ͘ͳ͍ͬͯ͘