mirror of
https://github.com/tachyons-css/tachyons.git
synced 2026-02-06 14:26:46 +00:00
Allow body class configuration with json front matter
This commit is contained in:
parent
f305ffb0eb
commit
ed92fce4b5
@ -3,6 +3,7 @@ var _ = require('lodash')
|
||||
var path = require('path')
|
||||
var glob = require('glob')
|
||||
var titleize = require('titleize')
|
||||
var fm = require('json-front-matter')
|
||||
var rmHtmlExt = require('remove-html-extension')
|
||||
|
||||
glob('examples/components/src/**/*.html', {}, function (err, components) {
|
||||
@ -14,14 +15,15 @@ glob('examples/components/src/**/*.html', {}, function (err, components) {
|
||||
var template = fs.readFileSync('examples/components/component-template.html', 'utf8')
|
||||
|
||||
components.forEach(function (component) {
|
||||
var title = getTitle(component)
|
||||
var newDir = rmHtmlExt(component.replace('/src', '')) + '/index.html'
|
||||
var componentHtml = fs.readFileSync(component)
|
||||
var componentHtml = fs.readFileSync(component, 'utf8')
|
||||
|
||||
console.log(newDir)
|
||||
console.log(title)
|
||||
var fmParsed = fm.parse(componentHtml)
|
||||
var frontMatter = fmParsed.attributes || {}
|
||||
frontMatter.title = frontMatter.title || getTitle(component)
|
||||
frontMatter.content = fmParsed.body
|
||||
|
||||
var compiledPage = _.template(template)({ title: title, content: componentHtml })
|
||||
var compiledPage = _.template(template)(frontMatter)
|
||||
fs.writeFileSync(newDir, compiledPage)
|
||||
})
|
||||
})
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="/css/tachyons.min.css">
|
||||
</head>
|
||||
<body class="wi-100 sans-serif bg-light-gray">
|
||||
<body class="wi-100 sans-serif <%= bodyClass %>">
|
||||
<main>
|
||||
<%= content %>
|
||||
</main>
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="/css/tachyons.min.css">
|
||||
</head>
|
||||
<body class="wi-100 sans-serif bg-light-gray">
|
||||
<body class="wi-100 sans-serif bg-dark-purple">
|
||||
<main>
|
||||
<form action="index_submit" method="get" accept-charset="utf-8" class="pvl mvxl">
|
||||
<fieldset class="center mw6-ns phm phl-ns bn">
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
{{{
|
||||
"bodyClass" : "bg-light-gray"
|
||||
}}}
|
||||
|
||||
<form action="index_submit" method="get" accept-charset="utf-8" class="pvl mvxl">
|
||||
<fieldset class="center mw6-ns phm phl-ns bn">
|
||||
<legend class="bold ttu tracked-mega plm pln-ns pvm f3-ns lightest-purple dn">Sign In</legend>
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
{{{
|
||||
"bodyClass": "bg-dark-purple"
|
||||
}}}
|
||||
<form action="index_submit" method="get" accept-charset="utf-8" class="pvl mvxl">
|
||||
<fieldset class="center mw6-ns phm phl-ns bn">
|
||||
<legend class="semibold ttu tracked-mega plm pln-ns pvm f3-ns black-80">Sign Up</legend>
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
"glob": "^5.0.15",
|
||||
"gzip-size": "^3.0.0",
|
||||
"immutable-css": "^0.1.0",
|
||||
"json-front-matter": "^1.0.0",
|
||||
"lodash": "^3.10.0",
|
||||
"node-minify": "^1.2.0",
|
||||
"node-sass": "^0.9",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user