Skip to content

Commit aca72cf

Browse files
committed
Add metadata we have in front-matter into HTML head meta tags
1 parent 5dd715e commit aca72cf

File tree

13 files changed

+117
-45
lines changed

13 files changed

+117
-45
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
.npm
1+
.npm/
22
node_modules/
3+
bower_components/
34
build/
45
npm-debug.log
56
src/
6-
static/assets/css/highlight.css
7+
static/assets/css/highlight.css

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
SHELL := bash
22
PATH := bin:${PATH}
33
DATE := `date '+%Y%m%d'`
4-
THIS_DIR:=$(shell pwd)
4+
55

66
build: src/ node_modules/ static/assets/css/highlight.css
77
time npm run build
@@ -28,6 +28,7 @@ rsync:
2828
rsync -az --delete --progress --exclude=".git" build/ upstream-docs1.staging.wpdn:/srv/webapps/docs/build/
2929
rsync -az config/nginx/ upstream-docs1.staging.wpdn:/etc/nginx/docs/
3030

31+
3132
nas:
3233
rsync -a --delete --progress --exclude=".git" build/ /Volumes/web/webplatform/
3334

build.js

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,43 @@
1-
var metalsmith = require('metalsmith')
2-
,changed = require('metalsmith-changed')
3-
,layouts = require('metalsmith-layouts')
4-
,assets = require('metalsmith-assets')
5-
,remarkable = require('metalsmith-markdown-remarkable')
6-
,syntaxHighlighter = require('./lib/remarkable/highlighter')
7-
,remarkablePlugin = require('./lib/remarkable/extender')
8-
,pkg = require('./package.json');
1+
2+
/**
3+
* Build static HTML files using Metalsmith
4+
*/
5+
6+
var metalsmith = require("metalsmith")
7+
,changed = require("metalsmith-changed")
8+
,layouts = require("metalsmith-layouts")
9+
,assets = require("metalsmith-assets")
10+
,remarkable = require("metalsmith-markdown-remarkable")
11+
,remarkableHighlighter = require("./lib/remarkable/highlighter")
12+
,remarkableExtender = require("./lib/remarkable")
13+
,handlebarsExtender = require("./lib/handlebars")()
14+
,pkg = require("./package.json");
915

1016
metalsmith(__dirname)
1117
.clean(false)
1218
.use(changed())
13-
.source('./src')
14-
.destination('./build')
15-
.use(remarkable('full', {
16-
breaks: true,
17-
typographer: true,
18-
html: true,
19-
langPrefix: '',
20-
highlight: syntaxHighlighter
21-
}).use(remarkablePlugin))
19+
.source("./src")
20+
.destination("./build")
21+
.use(remarkable("full", {
22+
html: true
23+
,breaks: true
24+
,typographer: true
25+
,langPrefix: ""
26+
,highlight: remarkableHighlighter
27+
}).use(remarkableExtender))
2228
.use(layouts({
23-
engine: "handlebars",
24-
default: "default.hbs"
29+
engine: "handlebars"
30+
,default: "default.hbs"
31+
,partials: "partials"
2532
}))
2633
.use(assets({
27-
source: "./static",
28-
destination: "./"
34+
source: "./static"
35+
,destination: "./"
2936
}))
3037
.build(function (err) {
3138
if (err) {
3239
console.log(err);
33-
}
34-
else {
35-
console.log('Site build complete!');
40+
} else {
41+
console.log("Site build complete!");
3642
}
3743
});

layouts/default.hbs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
<!DOCTYPE html>
22
<html lang="en" dir="ltr" class="client-nojs">
33
<head>
4-
<meta charset="UTF-8">
4+
<meta charset="UTF-8" />
55
<title>{{title}} · WebPlatform Docs</title>
66
<link rel="stylesheet" href="/assets/css/docs.css" />
77
<link rel="stylesheet" href="/assets/css/highlight.css" />
8-
<style>body{background-color:#efeadd !important;}.Almost_Ready{background:#E3CE21;}.In_Progress{background:#F29A3D;}.Not_Ready{background:#CF4732;}.Not_Ready p,.Not_Ready p a{color:#fff;}.Out_of_Date{background:#aaa;}.Ready_to_Use{background:#7BC649;}.readiness-state{-ms-transform:rotate(-90deg);-webkit-transform:rotate(-90deg);border-radius:0 25px 25px 0;box-sizing:border-box;left:-981px;padding:0 45px 0 20px;position:fixed;top:987px;transform:rotate(-90deg);width:2000px;}.readiness-state p{background:url(//www.webplatform.org/assets/white-circle.svg) right center no-repeat;box-sizing:border-box;color:#333;font-family:Bitter,Cambria,Georgia,serif;font-style:italic;margin:0 -34px 0 0;padding:6px 140px 6px 20px;text-align:right;}.readiness-state p a{color:#333;font-size:18px;font-style:normal;font-weight:700;margin-left:6px;text-decoration:underline;}#main-content img{max-width:100%;}</style>
98
<link rel="shortcut icon" href="/favicon.ico" />
109
<meta name="viewport" content="width=device-width" />
1110
<!--[if lt IE 7]><script src="//www.webplatform.org/assets/bower_components/ie7-js/lib/IE7.js"></script><![endif]-->
1211
<!--[if lt IE 8]><script src="//www.webplatform.org/assets/bower_components/ie7-js/lib/IE8.js"></script><![endif]-->
1312
<!--[if lt IE 9]><script src="//www.webplatform.org/assets/bower_components/ie7-js/lib/IE9.js"></script><![endif]-->
1413
<!--[if lt IE 9]><script src="//docs.webplatform.org/w/extensions/WebPlatformDocs/skin/html5shiv.js"></script><![endif]-->
1514
<!--[if lt IE 8]><link rel="stylesheet" href="//www.webplatform.org/assets/css/ie7.css"><![endif]-->
15+
{{>metadata}}
16+
1617
</head>
1718
<body class="mediawiki ltr sitedir-ltr skin-webplatform action-view">
1819
<header id="mw-head" class="noprint">
@@ -66,6 +67,7 @@
6667
<div id="main-content">
6768
<h1>{{title}}</h1>
6869
{{{ contents }}}
70+
{{>attributions}}
6971
</div>
7072
<div class="topics-nav">
7173
<ul>

lib/handlebars/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
/**
3+
* Handlebars helpers registry
4+
*/
5+
6+
var Remarkable = require('remarkable')
7+
, Handlebars = require('handlebars');
8+
9+
module.exports = function () {
10+
'use strict';
11+
12+
// Helper stuff goes here.
13+
14+
};

lib/remarkable/highlighter.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
/*!
1+
2+
/**
23
* Syntax highlighter as a Remarkable Markdown renderer plugin.
34
*
45
* https://github.com/jonschlinkert/remarkable
56
* https://www.npmjs.com/package/remarkable#options
67
*/
78

8-
'use strict';
9-
109
var hljs = require('highlight.js');
1110

1211
/**
@@ -15,7 +14,8 @@ var hljs = require('highlight.js');
1514
* Roughly an adaptation of the syntax highlight
1615
* example function provided in Remarkable documentation.
1716
*/
18-
module.exports = function metalsmithRemarkableSyntaxHighlighter (str, lang) {
17+
module.exports = function (str, lang) {
18+
'use strict';
1919

2020
if (lang && hljs.getLanguage(lang)) {
2121
try {

lib/remarkable/extender.js renamed to lib/remarkable/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
'use strict';
21

32
/**
4-
* A Remarkable parser configuration object as plugin.
3+
* Remarkable parser configuration.
54
*/
5+
66
module.exports = function (instance, options) {
7+
'use strict';
78

89
instance.block.ruler.enable([
910
'deflist'

package.json

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,37 @@
22
"name": "generator-docs",
33
"version": "2.0.0",
44
"description": "WebPlatform Docs Static site generator",
5-
"author": "Renoir Boulanger <[email protected]>",
5+
"homepage": "https://github.com/webplatform/generator-docs#readme",
66
"license": "CC-BY-3.0",
7-
"main": "build.js",
8-
"engines": {
9-
"node": ">=0.12"
10-
},
7+
"authors": [
8+
"Renoir Boulanger <[email protected]>"
9+
],
1110
"bugs": {
1211
"url": "https://github.com/webplatform/generator-docs/issues"
1312
},
14-
"homepage": "https://github.com/webplatform/generator-docs#readme",
1513
"repository": {
1614
"type": "git",
1715
"url": "git+https://github.com/webplatform/generator-docs.git"
1816
},
17+
"main": "build.js",
18+
"engines": {
19+
"node": ">=4"
20+
},
1921
"scripts": {
2022
"serve": "node serve",
21-
"build": "node --harmony build"
23+
"build": "node build"
2224
},
2325
"dependencies": {
24-
"express": "^4.13.3",
2526
"handlebars": "^2.0",
27+
"remarkable": "^1.6.0",
2628
"highlight.js": "^8.8.0",
2729
"metalsmith": "~2",
2830
"metalsmith-assets": "^0.1.0",
2931
"metalsmith-changed": "~0.2",
3032
"metalsmith-layouts": "~1.4",
3133
"metalsmith-markdown-remarkable": "^0.1.1"
34+
},
35+
"devDependencies": {
36+
"express": "^4.13.3"
3237
}
3338
}

partials/attributions.hbs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{{!<h2>Attributions</h2>
2+
{{attributions.length}}
3+
<ul>
4+
{{#attributions}}
5+
<li>Hi</li>
6+
{{/attributions}}
7+
</ul>
8+
}}

partials/metadata.hbs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{{#readiness}}<meta name="readiness" content="{{.}}" />{{/readiness}}
2+
{{#standardization_status}}<meta name="standardization" content="{{.}}" />{{/standardization_status}}
3+
{{#summary}}<meta name="description" content="{{.}}" />{{/summary}}
4+
{{#each attributions}}
5+
<meta name="attribution" content="{{.}}" />
6+
{{/each}}

0 commit comments

Comments
 (0)