diff --git a/anchor.md b/anchor.md new file mode 100644 index 0000000..3686735 --- /dev/null +++ b/anchor.md @@ -0,0 +1,563 @@ +title: Add Anchor Links to Your Website + + +%css + +pre { + padding: 4px 4px 4px 4px; + border-top: #bbb 1px solid; + border-bottom: #bbb 1px solid; + background: #f3f3f3; +} + +%end + + +# Agenda + + +- What's a static site generator? +- Case Study - Dr. Jekyll and Mr Hyde Novella +- Why Static? + - The "Classic" Dynamic Site Generators + - Faster, Simpler, Prettier + - Static is the New Dynamic +- Static Site Generators in JavaScript +- Add Anchor Links to Your Static Site + - V1.0 + - V2.0 + - V3.0 + - V4.0 w/ JavaScript + - V5.0 w/ Anchor.js + - Anchor.js Options + - More Examples + + +# What's a static site generator? + +Turns a bunch of files e.g. + +- plain text documents +- hypertext documents, building blocks, templates and layouts +- datafiles +- and much more + +into ready-to-serve, ready-to-use (static) web sites. + + +# Case Study - Another Awesome Blog + +Turn text such as: + +`_posts/2015-09-30-what-s-javascript.md`: + +``` +## What's Javascript? + +JavaScript (/ˈdʒɑːvəˌskrɪpt/) is a high level, dynamic, untyped, and interpreted +programming language. It has been standardized in the ECMAScript language specification. +Alongside HTML and CSS, it is one of the three essential technologies +of World Wide Web content production; the majority of websites employ it and +it is supported by all modern web browsers without plug-ins. +``` + +Using some "magic" into a ready-to-serve blog (static site). + +Just kidding ;-) not yet another awesome blog; let's try something new +e.g. let's build a single-page book (static site). + + +# Case Study - Dr. Jekyll and Mr Hyde Novella + +Turns text such as: + +`01.md`: + +``` +## Story of the Door + +Mr. Utterson the lawyer was a man of a rugged countenance, that was +never lighted by a smile; cold, scanty and embarrassed in +discourse; backward in sentiment; lean, long, dusty, dreary, and +yet somehow lovable. At friendly meetings, and when the wine was to +his taste, something eminently human beaconed from his eye +... +``` + +`02.md`: + +``` +## Search for Mr. Hyde + +That evening Mr. Utterson came home to his bachelor house in sombre +spirits and sat down to dinner without relish. It was his custom of +a Sunday, when this meal was over, to sit close by the fire, a +volume of some dry divinity on his reading-desk, until the clock of +the neighbouring church rang out the hour of twelve, when he would +go soberly and gratefully to bed. On this night, however, as soon as +... +``` + +(Source: [`worldclassics/dr-jekyll-and-mr-hyde`](https://github.com/worldclassics/dr-jekyll-and-mr-hyde)) + + + +# Case Study - Dr. Jekyll and Mr Hyde Novella (Cont.) + + +Add your chapters to the classics books theme (static site). For example: + +``` +├── _config.yml # book configuration +├── _chapters # sample chapters +| ├── 01.md +| ├── 02.md +| ├── ... +| └── 10.md +├── _layouts +| └── default.html # master layout template +├── css +| ├── _settings.scss # style settings (e.g. variables) +| └── style.scss # master style page +└── index.html # all-in-one page book template +``` + +Using: + +``` +$ jekyll build +``` + + +# Case Study - Dr. Jekyll and Mr Hyde Novella (Cont.) + +Will result in an all-in-one single page book (static site): + +``` +└── _site # output build folder; site gets generated here + ├── css + | └── style.css # styles for pages (copied 1:1 as is) + └── index.html # all-in-one book page +``` + +Example: + + + + +(Live Demo: [`drjekyllthemes.github.io/jekyll-book-theme`](http://drjekyllthemes.github.io/jekyll-book-theme)) + + +# Static in the "Real World" + +- Books +- Magazines +- Newspapers +- etc. + +### Trivia Quiz + +Strange Case of Dr Jekyll and Mr Hyde by Robert Louis Stevenson + +Q: Last Update In (Static Since) ______ ? + +- [ A ] 1854 +- [ B ] 1886 +- [ C ] 1921 +- [ D ] 2007 + + +# Why Static? - The "Classic" Dynamic Site Generators + +**The Biggies** (PHP Rules!) + +- WordPress +- Drupal +- Joomla + +On your live production site requires + +- database (e.g. mysql) +- application server (e.g. mod_php) +- web server (e.g. apache) + + +# Why Static? - Faster, Simpler, Prettier + +- Fast, Faster, Fastest + +- Simple, Simpler, Simplest + +- Pretty, Prettier, Prettiest + - e.g. designer nirvana - do-it-yourself - full control over your design; use Bootstrap, Material, or what not. + +Bonus: Secure - invite all the hackers - basically unbreakable! + +There are only static files on your server. +If an attacker hacks your server, there's "just" some "temporary" data loss. +To recover +- Regenerate your site on your local machine. +- Upload it again to the server or shutdown the old "hacked" server and use a new server + and you're back in action. + + +# Why Static? - Static is the New Dynamic + +Back to the future. Build sites like it's 1995. + + + +Q: Any Vim Users? Anything like that in Vim? + + + + + + +# Trivia Quiz - The Great Gatsby + +Q: Written by ________ ? + +- [ A ] D. H. Lawrence +- [ B ] F. Scott Fitzgerald +- [ C ] Ian S. Taylor +- [ D ] Kyle A. Mathews + +Q: Last Update in _____ ? + +- [ A ] 1885 +- [ B ] 1925 +- [ C ] 1995 +- [ D ] 2015 + + +# What's Gatsby? (Yet Another) Static Site Generator (in JavaScript) + +Started in 2015 by Kyle Mathews - Gatsby is - +surprise, surprise - (yet another) static site generator in JavaScript +that turns plain text into dynamic blogs and sites using +Webpack modules and React.js components and routing machinery. + +Find out more @ [gatsbyjs/gatsby](https://github.com/gatsbyjs/gatsby). + + + +# More Static Site Generators in JavaScript (& CoffeeScript) + +The Biggies + +- Hexo +- Metalsmith +- Wintersmith +- Blacksmith +- Harp +- Assemble +- GitBook +- and many more + +Q: What static site generators (in JavaScript) +do you use? Anyone? + + + + +# Add Anchor Links to Your Static Site + +What's an anchor link? + +Let's you (deep) link a heading or paragraph inside a page. + +Example - link to the "License" section - use: `README.md#license` + + + + +Example - link to "Automate, Automate, Automate" section - use: `README.md#automate-automate-automate` + + + + + + + +# Add Anchor Links to Your Static Site - Cont. + + +Step 1: Add id attribute to heading + +Before + +``` +