73
Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds!

Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Angular 2 and HexoStatic Meets Dynamic For the Best of Both Worlds!

Page 2: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Who am I?

Jeff Ammons

Microsoft MVP

Pluralsight Author

CEO/Chief Instructor at Code Career

Academy

25 Years Professional Experience in Software

Page 3: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

What is a Static Website Generator?

• Store content as text files of Markdown and YAML

Page 4: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Sample Post Format

Page 5: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Sample Post Format

YAML

Page 6: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Sample Post Format

YAML

Markdown

Page 7: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Sample Post Format

YAML

Markdown

Rendered HTML Output

Page 8: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

What is a Static Website Generator?

• Store content as text files of Markdown and YAML

• Run processor locally to convert to HTML files

Page 9: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

What is a Static Website Generator?

• Store content as text files of Markdown and YAML

• Run processor locally to convert to HTML files

• Version with Git

Page 10: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

What is a Static Website Generator?

• Store content as text files of Markdown and YAML

• Run processor locally to convert to HTML files

• Version with Git

• Deploy with Git

Page 11: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

What is a Static Website Generator?

• Store content as text files of Markdown and YAML

• Run processor locally to convert to HTML files

• Version with Git

• Deploy with Git

• Serve plain files via any web server

Page 12: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Why Would I Want One?

•Speed

•Scalability

•Reliability

•Lower Attack Surface

•Version Control

•Tools

•Zero Lock-in

Page 13: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

When does it make sense?

• Primarily content site

• Blog

• “Brochure-ware” Site

Page 14: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

When does it NOT make sense?

• Everything else…

• It’s not called a “General Purpose Site Generator”…

Page 15: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Traditional CMS: Writing

Page 16: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Traditional CMS: Writing

Page 17: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Traditional CMS: Writing

Page 18: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Traditional CMS: Reading

Page 19: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Traditional CMS: Reading

Page 20: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Traditional CMS: Reading

Page 21: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Traditional CMS: Reading

Page 22: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Traditional CMS: Reading

Page 23: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Traditional CMS: Reading

Page 24: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Traditional CMS: Reading

Page 25: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Traditional CMS: Reading

Page 26: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Static Site Generator: Writing

Page 27: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Static Site Generator: Writing

Page 28: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Static Site Generator: Writing

Page 29: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Static Site Generator: Generating

Page 30: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Static Site Generator: Generating

Page 31: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Static Site Generator: Generating

Page 32: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Static Site Generator: Generating

Page 33: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Static Site Generator: Generating

Page 34: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Static Site Generator: Generating

Page 35: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Static Site Generator: Generating

Page 36: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Static Site Generator: Generating

Page 37: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Static Site Generator: Publishing

Page 38: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Static Site Generator: Publishing

Page 39: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Static Site Generator: Publishing

Page 40: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Static Site Generator: Reading

Page 41: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Static Site Generator: Reading

Page 42: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Static Site Generator: Reading

Page 43: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Static Site Generator: Scaling

Page 44: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Static Site Generator: Scaling

Page 45: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Static Site Generator: Scaling

Page 46: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

YAML

Markdown

CommonPost Format

Page 47: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

YAML

YAML Ain't Markup Language

YAML is a human friendly data serialization

standard for all programming languages.

Source: yaml.org

Page 48: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Markdown

Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML).

Source: http://daringfireball.net/projects/markdown/

Page 49: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Sample Post Format

Page 50: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Sample Post Format

YAML

Page 51: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Sample Post Format

YAML

Markdown

Page 52: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Sample Post Format

YAML

Markdown

Rendered HTML Output

Page 53: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Prerequisites

• Node.js

• Npm

• Git

• Text editor

Page 54: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Which Text Editor Should I Use?

• Sublime Text

• Visual Studio Code

• Atom

• Notepad++

• Vim

• Emacs

• [Insert any other editor you like here]

Page 55: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Hexo

• Super simple

• Fast

• Easy to work with

Page 56: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Super Easy Install

npm install hexo-cli -g

Page 57: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Create a New Blog

hexo init

npm install

Page 58: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Create a New post

hexo new “My New Post”

hexo new post “My New Post”

Page 59: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Test Blog Locally

hexo server

Page 60: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Generate Blog for Publishing

hexo generate

Page 61: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Just Enough Git

git init

git add .

git commit –m “My commit message”

git push origin master

Page 62: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Where Can I Deploy my Blog?

• GitHub Pages

• Azure Web App

• Windows Server

• Linux Server

• Raspberry Pi

• … Any web server

Page 63: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

For Full Instructions…

• Check out my Pluralsight course!

• Build a Better Blog with a Static Site Generator

• https://www.pluralsight.com/courses/static-site-generator-build-better-blog

Page 64: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

How About the Dynamic Bits??

• Hexo Widgets

• UI Elements supported by many themes

• Angular 2 Components are a nice fit

• Keep the static bits static and the dynamic bits dynamic!

Page 65: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM
Page 66: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Dynamic

Widget

Page 67: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Seasoning

• Dynamic widgets should be the salt and pepper on static content sites

• Don’t over do it!

• Otherwise it was never really a static content site

Page 68: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Where can I get dynamic content?

• REST APIs

• Public APIs

• Your own API sites

• Pre-gen JSON files

• Pre-gen HTML fragment

Page 69: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Example Widget/Component Sources

Meetup.com

Page 70: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Example Widget/Component Sources

MySite.com

Node.js

Ruby on Rails

ASP.NET

Page 71: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Example Widget/Component Sources

MySite.com

Node.js

Ruby on Rails

ASP.NET

OAUTH

Secure

the API

not the site

Page 72: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Resources

• https://hexo.io/

• https://www.staticgen.com/

• https://www.pluralsight.com/courses/static-site-generator-build-better-blog

• http://ammonsonline.com/top-5-reasons-to-blog-with-a-static-file-generator/

Page 73: Angular 2 and Hexo - jeffa.techTitle: Angular 2 and Hexo Author: Jeff Ammons Created Date: 9/21/2016 4:20:21 PM

Contact Info

• https://www.pluralsight.com/authors/jeff-ammons

• Company: http://codecareeracademy.com

• Twitter: jeffa00

• Linked-In: jeffammons

• Blog: http://jeffa.tech

• User Group: http://ggmug.com