-
Notifications
You must be signed in to change notification settings - Fork 2
/
anchor.html
687 lines (493 loc) · 17.6 KB
/
anchor.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Add Anchor Links to Your Website</title>
<meta name="generator" content="Slide Show (S9) v2.5.0 on Ruby 2.1.5 (2014-11-13) [i386-mingw32]">
<meta name="author" content="Your Name Here" >
<!-- helper/macro that lets you add (CSS3) gradient using headers
see http://slideshow.rubyforge.org/themes.html
-->
<!-- S6 style sheet links -->
<link rel="stylesheet" href="anchor.css" media="projection" id="styleProjection">
<link rel="stylesheet" href="s6/screen.css" media="screen" id="styleScreen">
<link rel="stylesheet" href="s6/print.css" media="print">
<!-- S6 JS -->
<script src="s6/jquery.js"></script>
<script src="s6/jquery.slideshow.js"></script>
<script>
$(document).ready( function() {
Slideshow.init();
} );
</script>
<!-- Better Browser Banner for Microsoft Internet Explorer (IE) -->
<!--[if IE]>
<script src="s6/jquery.microsoft.js"></script>
<![endif]-->
</head>
<body>
<div class="layout">
<div id="header"></div>
<div id="footer">
<h1>Your Footer Here</h1>
<h2>Your Subfooter Here</h2>
</div>
</div>
<div class="presentation">
<div class='slide '>
<!-- === begin markdown block ===
generated by markdown/1.2.0 on Ruby 2.1.5 (2014-11-13) [i386-mingw32]
on 2015-09-30 18:33:08 +0200 with Markdown engine kramdown (1.5.0)
using options {}
-->
<!-- _S9SLIDE_ -->
<h1 id="agenda">Agenda</h1>
<ul>
<li>What’s a static site generator?</li>
<li>Case Study - Dr. Jekyll and Mr Hyde Novella</li>
<li>Why Static?
<ul>
<li>The “Classic” Dynamic Site Generators</li>
<li>Faster, Simpler, Prettier</li>
<li>Static is the New Dynamic</li>
</ul>
</li>
<li>Static Site Generators in JavaScript </li>
<li>Add Anchor Links to Your Static Site
<ul>
<li>V1.0</li>
<li>V2.0</li>
<li>V3.0</li>
<li>V4.0 w/ JavaScript</li>
<li>V5.0 w/ Anchor.js
<ul>
<li>Anchor.js Options</li>
<li>More Examples</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="whats-a-static-site-generator">What’s a static site generator?</h1>
<p>Turns a bunch of files e.g.</p>
<ul>
<li>plain text documents</li>
<li>hypertext documents, building blocks, templates and layouts</li>
<li>datafiles</li>
<li>and much more</li>
</ul>
<p>into ready-to-serve, ready-to-use (static) web sites.</p>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="case-study---another-awesome-blog">Case Study - Another Awesome Blog</h1>
<p>Turn text such as:</p>
<p><code>_posts/2015-09-30-what-s-javascript.md</code>:</p>
<pre><code>## 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.
</code></pre>
<p>Using some “magic” into a ready-to-serve blog (static site).</p>
<p>Just kidding ;-) not yet another awesome blog; let’s try something new
e.g. let’s build a single-page book (static site).</p>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="case-study---dr-jekyll-and-mr-hyde-novella">Case Study - Dr. Jekyll and Mr Hyde Novella</h1>
<p>Turns text such as:</p>
<p><code>01.md</code>:</p>
<pre><code>## 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
...
</code></pre>
<p><code>02.md</code>:</p>
<pre><code>## 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
...
</code></pre>
<p>(Source: <a href="https://github.com/worldclassics/dr-jekyll-and-mr-hyde"><code>worldclassics/dr-jekyll-and-mr-hyde</code></a>)</p>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="case-study---dr-jekyll-and-mr-hyde-novella-cont">Case Study - Dr. Jekyll and Mr Hyde Novella (Cont.)</h1>
<p>Add your chapters to the classics books theme (static site). For example:</p>
<pre><code>├── _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
</code></pre>
<p>Using:</p>
<pre><code>$ jekyll build
</code></pre>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="case-study---dr-jekyll-and-mr-hyde-novella-cont-1">Case Study - Dr. Jekyll and Mr Hyde Novella (Cont.)</h1>
<p>Will result in an all-in-one single page book (static site):</p>
<pre><code>└── _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
</code></pre>
<p>Example:</p>
<p><img src="i/jekyll-n-hyde-book.png" alt="" /></p>
<p>(Live Demo: <a href="http://drjekyllthemes.github.io/jekyll-book-theme"><code>drjekyllthemes.github.io/jekyll-book-theme</code></a>)</p>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="static-in-the-real-world">Static in the “Real World”</h1>
<ul>
<li>Books</li>
<li>Magazines</li>
<li>Newspapers</li>
<li>etc.</li>
</ul>
<h3 id="trivia-quiz">Trivia Quiz</h3>
<p>Strange Case of Dr Jekyll and Mr Hyde by Robert Louis Stevenson </p>
<p>Q: Last Update In (Static Since) <strong>__</strong> ?</p>
<ul>
<li>[ A ] 1854</li>
<li>[ B ] 1886</li>
<li>[ C ] 1921</li>
<li>[ D ] 2007</li>
</ul>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="why-static---the-classic-dynamic-site-generators">Why Static? - The “Classic” Dynamic Site Generators</h1>
<p><strong>The Biggies</strong> (PHP Rules!)</p>
<ul>
<li>WordPress</li>
<li>Drupal</li>
<li>Joomla</li>
</ul>
<p>On your live production site requires</p>
<ul>
<li>database (e.g. mysql)</li>
<li>application server (e.g. mod_php)</li>
<li>web server (e.g. apache)</li>
</ul>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="why-static---faster-simpler-prettier">Why Static? - Faster, Simpler, Prettier</h1>
<ul>
<li>
<p>Fast, Faster, Fastest</p>
</li>
<li>
<p>Simple, Simpler, Simplest</p>
</li>
<li>
<p>Pretty, Prettier, Prettiest</p>
<ul>
<li>e.g. designer nirvana - do-it-yourself - full control over your design; use Bootstrap, Material, or what not.</li>
</ul>
</li>
</ul>
<p>Bonus: Secure - invite all the hackers - basically unbreakable!</p>
<p>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.</p>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="why-static----static-is-the-new-dynamic">Why Static? - Static is the New Dynamic</h1>
<p>Back to the future. Build sites like it’s 1995.</p>
<p><img src="i/tweet-hublo.png" alt="" /></p>
<p>Q: Any Vim Users? Anything like that in Vim? </p>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="trivia-quiz---the-great-gatsby">Trivia Quiz - The Great Gatsby</h1>
<p>Q: Written by <strong>__</strong>__ ?</p>
<ul>
<li>[ A ] D. H. Lawrence </li>
<li>[ B ] F. Scott Fitzgerald</li>
<li>[ C ] Ian S. Taylor</li>
<li>[ D ] Kyle A. Mathews</li>
</ul>
<p>Q: Last Update in _____ ?</p>
<ul>
<li>[ A ] 1885</li>
<li>[ B ] 1925 </li>
<li>[ C ] 1995</li>
<li>[ D ] 2015</li>
</ul>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="whats-gatsby-yet-another-static-site-generator-in-javascript">What’s Gatsby? (Yet Another) Static Site Generator (in JavaScript)</h1>
<p>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.</p>
<p>Find out more @ <a href="https://github.com/gatsbyjs/gatsby">gatsbyjs/gatsby</a>.</p>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="more-static-site-generators-in-javascript--coffeescript">More Static Site Generators in JavaScript (& CoffeeScript)</h1>
<p>The Biggies</p>
<ul>
<li>Hexo</li>
<li>Metalsmith</li>
<li>Wintersmith</li>
<li>Blacksmith</li>
<li>Harp</li>
<li>Assemble</li>
<li>GitBook</li>
<li>and many more</li>
</ul>
<p>Q: What static site generators (in JavaScript)
do you use? Anyone? </p>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="add-anchor-links-to-your-static-site">Add Anchor Links to Your Static Site</h1>
<p>What’s an anchor link?</p>
<p>Let’s you (deep) link a heading or paragraph inside a page.</p>
<p>Example - link to the “License” section - use: <code>README.md#license</code></p>
<p><img src="i/readme-license.png" alt="" /></p>
<p>Example - link to “Automate, Automate, Automate” section - use: <code>README.md#automate-automate-automate</code></p>
<p><img src="i/readme-automate.png" alt="" /></p>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="add-anchor-links-to-your-static-site---cont">Add Anchor Links to Your Static Site - Cont.</h1>
<p>Step 1: Add id attribute to heading </p>
<p>Before</p>
<pre><code><h2>Search for Mr. Hyde</h2>
</code></pre>
<p>After</p>
<pre><code><h2 id="search-for-mr-hyde">Search for Mr. Hyde</h2>
</code></pre>
<p>Step 2: Use the anchor</p>
<p>Now you can use <code>#search-for-mr-hyde</code> to link to
the “Search for Mr. Hyde” heading.
That’s it.</p>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="add-anchor-links-to-your-static-site---v20">Add Anchor Links to Your Static Site - V2.0</h1>
<p>What’s new?</p>
<ul>
<li>Add a “permalink” marker e.g. <code>#</code></li>
</ul>
<p>Step 1: Add id attribute and a “permalink” marker to heading</p>
<p>Before</p>
<pre><code><h2>Search for Mr. Hyde</h2>
</code></pre>
<p>After</p>
<pre><code><h2 id="search-for-mr-hyde">
Search for Mr. Hyde
<a href="#search-for-mr-hyde">#</a>
</h2>
</code></pre>
<p>That’s it.</p>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="add-anchor-links-to-your-static-site---v30">Add Anchor Links to Your Static Site - V3.0</h1>
<p>What’s new?</p>
<ul>
<li>Only show “permalink” marker when hovering over heading</li>
</ul>
<p>Step 1: Add id attribute and a “permalink” marker to heading</p>
<p>Before</p>
<pre><code><h2>Search for Mr. Hyde</h2>
</code></pre>
<p>After</p>
<pre><code><h2 id="search-for-mr-hyde">
Search for Mr. Hyde
<a href="#search-for-mr-hyde" class="header-link">
<i class="fa fa-link"></i>
</a>
</h2>
</code></pre>
<p>Step 2: Add some CSS (styling)</p>
<pre><code>/* Let's use font awesome */
@font-face {
font-family: 'FontAwesome';
src: url('../fonts/fontawesome-webfont.eot?v=4.1.0');
src: url('../fonts/fontawesome-webfont.eot?#iefix&v=4.1.0') format('embedded-opentype'), url('../fonts/fontawesome-webfont.woff?v=4.1.0') format('woff'), url('../fonts/fontawesome-webfont.ttf?v=4.1.0') format('truetype'), url('../fonts/fontawesome-webfont.svg?v=4.1.0#fontawesomeregular') format('svg');
font-weight: normal;
font-style: normal;
}
.fa {
display: inline-block;
font-family: FontAwesome;
font-style: normal;
font-weight: normal;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.fa-link:before {
content: "\f0c1";
}
.header-link {
position: relative;
left: 0.5em;
opacity: 0;
font-size: 0.8em;
-webkit-transition: opacity 0.2s ease-in-out 0.1s;
-moz-transition: opacity 0.2s ease-in-out 0.1s;
-ms-transition: opacity 0.2s ease-in-out 0.1s;
}
h2:hover .header-link {
opacity: 1;
}
</code></pre>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="add-anchor-links-to-your-static-site-using-javascript---v40">Add Anchor Links to Your Static Site (using JavaScript) - V4.0</h1>
<p>What’s new?</p>
<ul>
<li>Let’s use JavaScript (jQuery)</li>
</ul>
<p>Turn</p>
<pre><code><h2 id="search-for-mr-hyde">Search for Mr. Hyde</h2>
</code></pre>
<p>into</p>
<pre><code><h2 id="search-for-mr-hyde">
Search for Mr. Hyde
<a href="#search-for-mr-hyde" class="header-link">
<i class="fa fa-link"></i>
</a>
</h2>
</code></pre>
<p>on page load e.g.:</p>
<pre><code>$(function() {
return $("h2").each( function(i, el) {
var $el, icon, id;
$el = $(el);
id = $el.attr('id');
icon = '<i class="fa fa-link"></i>';
$el.append($("<a />").addClass("header-link").attr("href", "#" + id).html(icon));
}
});
});
</code></pre>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="add-anchor-links-to-your-static-site-using-javascript---v50">Add Anchor Links to Your Static Site (using JavaScript) - V5.0</h1>
<p>What’s new?</p>
<ul>
<li>Let’s use pre-packaged JavaScript (e.g Anchor.js)</li>
</ul>
<p>What’s Anchor.js?</p>
<p><img src="i/anchorjs.png" alt="" /></p>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="add-anchor-links-to-your-static-site-using-javascript---v50-cont">Add Anchor Links to Your Static Site (using JavaScript) - V5.0 (Cont.)</h1>
<h2 id="step-1-include-script">Step 1: Include script</h2>
<pre><code><script src="anchor.js"></script>
</code></pre>
<h2 id="step-2--add-anchors-to-all-headings-h2s-on-the-page">Step 2: Add anchors to all headings (h2s) on the page</h2>
<pre><code>anchors.add('h1');
</code></pre>
<p>That’s it.</p>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="add-anchor-links-to-your-static-site-using-javascript---v50-cont-1">Add Anchor Links to Your Static Site (using JavaScript) - V5.0 (Cont.)</h1>
<h2 id="anchorjs-options">Anchor.js Options</h2>
<h3 id="placement"><code>placement</code></h3>
<ul>
<li><code>right</code> (default) => right appends the anchor to the end of the element</li>
<li><code>left</code> => left places it to the left, in the margin</li>
</ul>
<h3 id="visible"><code>visible</code></h3>
<ul>
<li><code>hover</code> (default) => hover displays the anchor when hovering over the element</li>
<li><code>always</code> => always will always display the anchor link</li>
</ul>
<h3 id="icon"><code>icon</code></h3>
<ul>
<li>(any character) => Replace the default link icon with the character(s) provided.
These are a few good options: #, ¶, and §.</li>
</ul>
<h3 id="class"><code>class</code></h3>
<ul>
<li>(any string) => Adds the provided class(es) to the anchor html.</li>
</ul>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="add-anchor-links-to-your-static-site-using-javascript---v50-cont-2">Add Anchor Links to Your Static Site (using JavaScript) - V5.0 (Cont.)</h1>
<p>Example 1:</p>
<ul>
<li>Add anchors to all h1s, h2s and h3s inside of #post.</li>
<li>Anchors will be always visible.</li>
</ul>
<pre><code>anchors.options.visible = 'always';
anchors.add('#post h1, #post h2, #post h3');
</code></pre>
<p>Example 2:</p>
<ul>
<li>Provide options as an object before adding anchors to the page.</li>
<li>Adds always-visible ¶ anchors in the left margin of each paragraph tag inside .story</li>
</ul>
<pre><code>anchors.options = {
placement: 'left',
visible: 'always',
icon: '¶'
};
anchors.add('.story > p');
</code></pre>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="viennahtml---join-us---no-database-required">Vienna.html - Join Us - No Database Required</h1>
<h3 id="whats-viennahtml">What’s Vienna.html?</h3>
<ul>
<li>Europe’s 1st Static Site User Group. Follow along @viennahtml
on Twitter and sign-up on GitHub with a pull request using
a static site datafile. Yes, you can.</li>
</ul>
<h3 id="next-first-meetups">Next (First) Meetups</h3>
<p><strong>October</strong></p>
<p>Late October. “Joint” meetup with Vienna.rb at Sektor 5.</p>
<p>“Dr. Jekyll and Mr. Hyde” -
All about <code>drjekyll/drj</code> - the missing static site package manager
and <code>mrhyde/mrh</code> - the missing static site configuration script wizard.</p>
<p><strong>November</strong></p>
<p>First “regular” meetup in November at Sektor 5.</p>
<p><strong>Talks, talks, talks!</strong></p>
<p>Present about a great JavaScript static site generator, tool, or
practice, for example.</p>
<p><img src="i/viennahtml.png" alt="" /></p>
<!-- === end markdown block === -->
</div>
</div><!-- presentation -->
</body>
</html>