Soifyoualreadyhaveno J s andthenodepackagemanagerinstalledonyourcomputer, thenallyouhavetodoisjustskiptotheendofthevideoandyou'llseethepartwhere I actuallyinstallGatsby.
You'llnoticethat I havethisnewfolderthatwascreatedinsidemydocumentsfoldercalled G A Site.
Sothisisthefolderthatgottobecreatedforourproject.
So I'm justgonnaopenthisup, and I wanttosortoftalkyouthroughwhatallofthesedifferentthingsareinsideofheremightbe a littleintimidatingifyouhaven't workedwithsomethingthatlookslikethisBefore I dothat, though, I justwanttoshowyouhowwecanactuallybuildoursiteandseeitonline.
Aslongasthatserverisrunningtobackoverinthetexteditoragain, I justwanttotalkyouguysthroughsortofthedefaultfilesthatyou'llseenow.
Thereare a coupleofthingsinhererelatedtoknowJs, andoneofthosethingsisthisNodeModulesfolderandyou'llnoticeifyouclickdowninthisfolder, there's like a bunchofotherfoldersinsideofhere.
AndthenwehavethesepackagedotJasonfilesandthisisanotherfilethat's usedwithnoJsandtherewillbe a coupleinstanceswherewe'regonnahavetomodifythis.
Butforthemostpart, thepackagedotJasonfilebasicallyjustmanagesallthedependenciesandallsortofliketheoverallsettingsofyourno J s app, whichiswhatwehaverighthere.
Sopackageyes, packagethatJasonfileisimportant, Butforlikethenormallyusecases, youprobablywon't havetotouchitthatmuchSo, like I said, forthemostpart, thissourcefullthereisgonnabereallyimportant.
That's a basicoverviewofthefulldestructionandGatsby.
Soif I wastocomeoverhereandcreate a paragraph, and I createdthisparagraphatthesamelevelofthisdip, so I hadtheseairlikecalledsiblingElements.
When I savethepage, you'llnoticethat I getanerror, andthat's becauseitsaysyouhaven't JasonJSXelements.
Andso, really, althoughthislookslikewe'rewritingineachteam, l wereactuallywritingin a specialJavaScript, eachteamoutlikehybridlanguagecalledJSX, andit's basicallylike a waythatyoucanwritehtmlinsideof a job, a scriptfile.
Whatthisisgoingtodoisit's gonnaallowustouse a reactcomponent, andthatreactcomponentiscalledLink.
Andbasicallyallyouneedtoknowisthatwecanuse a thelinkcomponentorthelinktaginordertocreate a linkbetweenthepagesonoursite.
So I wanttocomedownhereintothisHTMLand I'm justgonnausethislinktax.
Sonowthatweimportedit, wecanuse a tagcalledLinkandthen I'm gonnasaylinktoAndthen I knew I wanttotaketheaddressofthepagethat I want a linkThio.
Ifyou'refamiliarwithnormalhtml, thenyou'llknowaboutthelike a normallink, whichisjustthe A tagandnormallywewouldjusttypelike a andthen a treff, andtheninsideofhere, wecouldputthepathofthepagethatwewantedtovisit.
ButsincethisisGod's being, sincewe'reusingreact, wehavetodoitthiswaysowecanusethislinkandtheninsidehere, I'm justgonnaputthiswholelinkedtolikepagetwoandthen I canputsometextinheresowe'llsaylikepageThio.
Andthenwecancloseoffthislinkjustlikethat.
Sowhatthiswilldoiscreate a linktopagetwoonourwebsite.
Now, if I hadoverhere, you'llseethatwehavethislink.
Andwhen I clickthislink, younoticethatwegetthisdevelopmentfor a fourpage.
Sobasically, for a fourpagenotfoundright, thispageisn't onourwebsite, andthat's kindof a problem.
Solet's comeoverhereintothisPagesfolderandwe'llmake a newfileand I'm justgonnacallitpagehyphen, toodotJs, Thisisgonnabeanotherjobscriptfile, and I wannajustactually, I'm justgonnagobackhere.
Wedon't getthisredscreenofdeath.
I wanttocomeoverheretothisindex, and I'm justgonnacopyallofthecodefrominhere, and I'lljustpacetheendofthisnewpage.
Thatwaywedon't havetowriteitout.
Wecanjusthaveit.
And I'm justgoingtogetridofsomeofthisstuff.
AndonthisnewpagewilljustsaythatthisisPagetwo.
Andsonowourlinkshouldactuallywork.
Sowhen I clickthispagetolink, itwillbringmetothispageonourwebsiteandseethatitdoesAnotherthingwecoulddowouldbecreateanotherlinkonthispageandwe'lllinkbacktothehomepage.
So I'm gonnacopythelinkthatwehaveoverhereand I'llbringithereintopagetwo.
Andnow, insteadoflinkingtopagetoweaken, justlinktothehomepage, whichisjust a FordSashaandwecansaygohome.
Sothefirstthing I wanttodoiscomeoverhereintothisPagesfolderand I'm gonnacreate a newfile.
We'rejustgonnacallthiscounterdotJsSoinsideofthiscounterfile, wearegoingtomakeourcounterandinourindexfile, I justwantoh, create a linksothatwecaneasilygettothiscounterpage, sothiswilljustlinkustothecounter.
Butallwehavetodoisjustaddin a littlebitoflogicintothisreactclassintothisGatsbyclass, anditwillstartworking.
Sothefirstthing I'm gonnadoisaddinwhat's called a constructor.
Souphere, I'm justgonnapasteinsomemorecode.
Soit's gonnalooklikethis.
Actually, thisisn't formattedverywell, butthisis a constructorfunction.
Sobasically, whatthisisdoingisthatthisgetscalledwheneverwecreatethisclassorwhateverwelikereloadthepageandit's settingthisvariablecalledstateandsostateis a variablethatbasicallyrepresentsthestateofthecomponent.
And I'm notgonnagettoomuchintowhatStatedoes.
Butforallyouneedtoknowfornowisjustthatinsideofthisstatevariableweakenstore a variablecalledcount.
Sobasicallyweakenstorethecurrentcountinsideofthisstateobjectsowecanstartaccountrightthereandthen I alsowanttoaddinsomeothercodeandit's actuallygoingtogointhecounter.
So I'm justgonnaputthisrighthereandyou'llnoticethatnow, insteadofjusthavingzeroherewhenwe'retryingtoaccessthecurrentcount, wehavesomethingthatsaysthisdotstatedotcountWhatthisisdoingisit's accessingthisstatevariableuphere.
Solet's saythatyouhave a bunchofdifferentfilesandfoldersandresourceisonyourwebsite, andnowyouwanttoserveitupon a Webserver, right?
Well, howcanweaccessallofthosefiles?
Inotherwords, upuntilnowwe'vebeentestingourwebsiteonthislocalhostdevelopmentserver, Butwhathappenswhenyouwanttotakethosefilesandputhimupon a serverofyourown.
Well, wecanactuallyuse a buildcommandinordertobuildourGatsbywebsite.
Sobasically, wecanexecute a certaincommandandthengas, wewillgooutandbuildallofourpagestogetherintostaticpagesthatwecanthencopyandpasteorFTPorwhateveroverontoourwebserver.
So I'm gonnashowyouhowtodothatreallyquick.
So I justwanttocdintomydirectory.
Andonce I'm insideofmyprojectdirectory, I canrun a simplecommand, whichisjustnpmrunbuild.
Andbasically, thisisjustgonnatellGatsbylike, Hey, wewanttobuildoursite, Clickenter, andthisisgonnagooffanddo a bunchofstuff.
It's gonnabuildupourentirewebsite.
Sooncethat's donebuilding, I wanttoheadovertomyfiletree.
Soinsideofthispublicfoolthat I wasgonnaopenitupandyou'llnoticethatthere's a bunchoffilesandthere's a bunchof, like, JavaScriptfilesinhereandstufflikethat.
Butbasicallythisisourentiresite.
Sothere's actually a lotofthesedifferentfiles, andthat's kindofwhatit's gonnabelike.
Soanytimethatyoumake a changetoyourwebsiteandyouwanttoregeneratethefiles, youcanactuallyjustrunthatNPMrunbuildcommandagain, andit'llbuildallthesefilesandit'llsortoflikeoverrideoverwritethepublicfolderanddoeverythingthatyouneededtodoinsideofthere.
Inthistutorial, I'm justgonnagiveyou a quickoverviewofusingcomponentsandreact.
Now, I couldmakeanentirecoursejusttalkingaboutusingcomponentsandreact.
Andifyou'renotfamiliarwithhowreactworksandhowcomponentswork, thenthiswilljustkindofgiveyou a briefoverviewofhowthesecomponentsworkandreallyjustsortofhelpyoutowrapyourmindaroundwhatwe'redoinghere.
So a componentinreactisbasicallyjust a collectionofJsaxeor a collectionofHTMLthathasmaybesomestyling, maybesomelogic, anditsortofcontainedinthisoneclassorthisonecontainer.
Andthebestwayformetoexplainthisisjusttokindofshowyousoearlierinthistutorial, wecreatedthiscounterdotJsclassandif I gooverheremywebsite, I canclickandyouseeThisisthecounter, andbasicallyallitdoesisjustincrementsandDeckermints a counterwhenyouclickthesebuttons.
Now, thisiswhat's called a reactcomponent.
Andsoyou'llnoticethatthewholecomponentisjustthisthingrightherehassomesomeofthisJSXfromthisEachteam l A stylestuffinhere, right?
Soinhere I couldpassthiscounter, forexample, like a colorso I couldsaycolorisequalThioandwouldjustpassinblue, and I canactuallyaccessthiscolorvariablefrominsidemycomponent.
So I'm hereinmycountercomponent, andif I wantedtoaccessthecolor, I couldbasicallyjusttypeoutsomethinglikethisso I candoopenandclosedcurlybrackets, andthen I couldtakethisdotprops, andthen I wanttotakethenameofthevariablethatwepassedit.
Andobviouslyyoucancreatemorethanjust a counterso I cancreate, youknow, a coupleofdozenofthesecomponentsandaddthemenonmywebsitelike I couldcreate a componentfor, like, a navigationlist.
I cancreate a pony, a componentfortheheaderofmywebsite.
I couldcreate a componentfor a button, ReallyDoesn't matter.
And a lotofthesepluginswerejustdevelopedbyGatsby, andthere's also a bunchofpluginsthatweredevelopedbythecommunityandtheseplugins d'oh, widevarietyofthings, allsortsofstuff, andtheycanreallyjustmakeyourwebsite a lotmorepowerful.
Sowhatyoushoulddoisjustkindofclickthroughthesepluginsandseeifanycatcher I see, ifanyyouknowyoumightbeusefulonyourwebsite.
Forexample, here's oneforGoogleAnalyticsinfor a lotoftheseplugins, theonesthatareofficialplugins.
So I wanttotalktoyouinthisvideoabout, youknow, indownloadingandinstallingyourownplugin, andinthisvideowe'reactuallygonnainstall a pluginfortypography, Jsandtypography.
Jsislike a CSSframeworkthatwecanuseinsideofourwebsitetokindofjustmakeitlookbetterandstyleit a littlebitbetterbydefault.
Thewaythatwedothatisbyfirstcomingovertothissourcefolder, and I wanttocreate a newfolderinsideofhere, and I'm justgonnacallitlayouts.
AndtheninsideofthisLayoffsfolder, wecancreate a newfile, andwe'lljustcallthisindexdotJsandindexdotJsisgonnabethedefaultlayoutthatallofthepagesonoursitearegoingtouseinhere.
It's basicallylike a Childrenfunctionthatit's calling, andit's insideofthesecurlybrackets, andwhatthiswillrepresentisthecontentofthepagethatwe'recurrentlyon.
Sojusttodemonstratethis, I willtypeoutsometext.
Sowe'regoingtosaylayoutandwell, statelyout.
Andwhen I goovertomywebsiteandactuallybeforewedothat, wheneveryoumake a newlayout, youneedtorestartyourdevelopmentserver.
So I'm gonnarestartmyGatsbyserverjustlikethat.
Andoncethat's donerestartingwhen I refreshthispage, you'llnoticethatnow, insteadofjusthavinghowtheworldandthisis a paragraph, wehavetheselayoutsofhere.
Andsolayoutissurroundingthecontentofmypage, and I actuallyhave a coupleotherpageshere.
I alsohavePagetwo, and I have, ah, Pagethree.
Soif I goovertoFord's slashpagetwo, it's thesamething.
Sobydefault, allthepagesareonourwebsitearegonnabeusingthislayout, andtheselayoutsareawesomebecauseoverhere, forexample, I coulddefinelike a headerformypage.
Andthiswilljustbe a reallysimpleheader.
Andthen I couldalsodefinelike a footordownhere, andthatheadonthatfootaregonnashowuponeverysinglepageinsideofourwebsite.
Sothismakesitreallyeasytodefine a layoutforallthepagesundersitesoyoucouldhaveyourheaderuphereandyourfootdownthereAndwheneveryouwant, changethewaythattheheadofthefooterlooks, Youonlyhavetochangeitrighthereonthislayoutspageareonthisindexfileinsidethelayoutsfolder.
Wecanputanyvariablesthatwewantaccessaboutoursiteso I couldputlike, title, andwecouldgiveourwebsite a titlesoyoucouldsay, like, draftAcademy's Website.
I couldalsogivethissomething, maybe, likeanauthor, andwecouldjustsaytheauthor's me, Mike.
Soobviouslythisisjustsomeverysimpledata, but I'm storingitaboutmywebsitenow.
What I candois I canconfigureeachoneofmypagestogooutandgrabthisinformation, andsomypageswillbeabletodisplaythewebsitetitleandthewebsiteauthor.
Andif I everwanttochangethose, I onlyhavetochangetheminthisconflictfile.
I don't havetotouchthepagesthatthey'repullingthisdata.
So I'm gonnaheadovertooneofmypages.
We'lljustgotoindexdotJsThisisthehomepage.
Andinhere, what I wanttodoismakesomesimplemodificationswhichwillallowmetograbthedatathatiscomingfromthisGatsbyconflictJsfile.
Sothefirstthing I wanttodoisaddwhat's called a graphQueelqueryandgraphicyouElysequeryinglanguagethatwasdevelopedbyFacebookanditwasdesignedtobeusedwithreact.