Browse Source

label templates and split out converter code into utilities

beginners-guide
Bucko 7 years ago
parent
commit
a62f907aa1
  1. 85
      guide-generator.js
  2. 484
      page-templates/guides-archive.html
  3. 5
      page-templates/guides-sidebar.html
  4. 12
      page-templates/guides-wrapper.html
  5. 5
      page-templates/page-wrapper.html
  6. 42
      sidebar-generator.js
  7. 101
      utils/createHTML.js

85
guide-generator.js

@ -1,8 +1,8 @@
const marked = require('marked');
const fs = require('fs');
const path = require('path');
const Prism = require('prismjs');
const PrismLanguages = require('prism-languages');
const createHTML = require('./utils/createHTML.js');
const guidesDir = path.resolve(__dirname, 'guides');
const markdownDir = path.resolve(__dirname, 'guides-markdown');
@ -23,6 +23,7 @@ args.forEach(arg => {
}
});
// Information on how to use the command. Retrieved with `--help` arg
if ( args.indexOf('--help') > -1 || args.length === 0 ) {
console.log('Build guides from markdown files. Available options are:');
console.log('\'--author\' e.g. `--author="JOHN SNOW"`');
@ -42,80 +43,6 @@ if ( args.indexOf('--help') > -1 || args.length === 0 ) {
return;
}
/******
Prepare the marked renderer
******/
const renderer = new marked.Renderer();
// Custom renderer for code snippet highlighting
const getPostMeta = (author='bcoin-org') => '<ul class="post-meta">'
+ '<li class="author">By ' + author + '</li>'
+ '</ul>';
// Custom renderer for top two level headers
renderer.heading = (text, level) => {
if (level == '2' || level == '1' ) {
let header = '<h2 class="post-title panel-title">'
+ text + '</h2>';
if (author) {
postMeta = getPostMeta(author)
header += postMeta;
}
return header;
} else {
return `<h${level}>${text}</h${level}>`;
}
}
renderer.code = function (code, language) {
if (language === 'post-author') {
// only return code block if wasn't set by argument
return postMeta ? '' : getPostMeta(code);
}
return `<pre class="line-numbers language-${language}">`
+ `<code class="line-numbers language-${language}">`
+ Prism.highlight(code, PrismLanguages[language])
+ '</code></pre>';
}
marked.setOptions({
renderer,
gfm: true,
});
const createHTML = markdownFile => {
const markdownString = fs.readFileSync(markdownFile, 'utf8');
// Assemble guide text container
let blogText = marked(markdownString);
// Get the guide html template and find start of guide section
const template = fs.readFileSync(path.resolve(markdownDir, 'guides-template.txt'))
.toString().split('\n');
const startText = 'START OF GUIDE'; // NOTE: Make sure to change this if the comment text changes
let startLine = 0;
for (let i=0; i <= template.length; i++) {
if (template[i].indexOf(startText) > -1) {
startLine = i + 1;
break;
}
}
template.splice(startLine, 0, blogText);
fs.writeFileSync(htmlFile, template.join('\n'));
console.log(`Finished ${path.basename(htmlFile)}`);
}
let markdownFile;
let htmlFile;
if (all) {
@ -129,7 +56,7 @@ if (all) {
console.log('Starting file conversion: ', file);
markdownFile = path.resolve(markdownDir, file);
htmlFile = path.resolve(guidesDir, file.replace(/\.[^/.]+$/, ".html"));
createHTML(markdownFile);
createHTML(markdownFile, markdownDir, htmlFile);
}
}
console.log('All files done!');
@ -137,7 +64,7 @@ if (all) {
} else {
markdownFile = path.resolve(markdownDir, file);
htmlFile = path.resolve(guidesDir, file.replace(/\.[^/.]+$/, ".html"));
createHTML(markdownFile);
createHTML(markdownFile, markdownDir, htmlFile, author, postMeta);
}
/** Notes for building out page template:
@ -145,7 +72,7 @@ if (all) {
- header (includes main nav)
- guides-wrapper (main content wrapper)
- guides-sidebar
- guides-wrapper
(insert guide content)
- footer
- footer-scripts
**/

484
page-templates/guides-archive.html

@ -0,0 +1,484 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>bcoin | Extending Bitcoin into Enterprise & Production</title>
<!-- Favicons -->
<!-- old
<link rel="shortcut icon" href="assets/images/bcoin-ico.png">-->
<!-- generated from http://www.favicon-generator.org/ -->
<link rel="apple-touch-icon" sizes="57x57" href="assets/images/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="assets/images/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="assets/images/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="assets/images/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="assets/images/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="assets/images/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="assets/images/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="assets/images/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="assets/images/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="assets/images/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="assets/images/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="assets/images/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="assets/images/favicon-16x16.png">
<link rel="manifest" href="assets/images/manifest.json">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="assets/images/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
<!-- Web Fonts -->
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300,400italic,400,600,700' rel='stylesheet'>
<link href='https://fonts.googleapis.com/css?family=Montserrat:700' rel='stylesheet' type='text/css'>
<!-- Bootstrap core CSS -->
<link href="assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Icon Fonts -->
<link href="assets/css/font-awesome.min.css" rel="stylesheet">
<link href="assets/css/simple-line-icons.css" rel="stylesheet">
<!-- Plugins -->
<link href="assets/css/magnific-popup.css" rel="stylesheet">
<link href="assets/css/owl.carousel.css" rel="stylesheet">
<link href="assets/css/flexslider.css" rel="stylesheet">
<link href="assets/css/animate.min.css" rel="stylesheet">
<!-- Template core CSS -->
<link href="assets/css/vertical.min.css" rel="stylesheet">
<link href="assets/css/template.css" rel="stylesheet">
<!-- Google Analytics Tracking -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-96446060-1', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<!-- PRELOADER -->
<div class="page-loader">
<div class="img-loader">Loading...
<!-- Bcoin logo in SVG -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 200 56" style="enable-background:new 0 0 200 56;" xml:space="preserve">
<g id="XMLID_108_">
<g id="XMLID_123_">
<path id="XMLID_124_" d="M8.4,51.8H3.2V4.2h5.2v19.2h0.8c1.2-2,2.8-3.6,4.8-4.7c2-1.1,4.3-1.6,6.7-1.6c2,0,4,0.4,5.8,1.2
c1.8,0.8,3.4,1.9,4.8,3.3c1.4,1.5,2.5,3.2,3.3,5.4s1.2,4.6,1.2,7.3v1.4c0,2.8-0.4,5.2-1.2,7.4c-0.8,2.1-1.9,3.9-3.3,5.4
c-1.4,1.5-3,2.6-4.9,3.3s-3.8,1.1-5.9,1.1c-1.1,0-2.2-0.1-3.3-0.4c-1.1-0.3-2.2-0.6-3.2-1.2c-1-0.5-1.9-1.2-2.8-1.9
c-0.8-0.7-1.6-1.6-2.1-2.7H8.4V51.8z M19.4,47.7c1.6,0,3.1-0.3,4.4-0.9c1.3-0.6,2.5-1.4,3.5-2.4c1-1,1.8-2.3,2.3-3.8
c0.6-1.5,0.8-3.2,0.8-5v-1.4c0-1.8-0.3-3.5-0.8-4.9c-0.6-1.5-1.3-2.7-2.3-3.8c-1-1.1-2.2-1.9-3.5-2.5c-1.4-0.6-2.8-0.9-4.4-0.9
c-1.6,0-3,0.3-4.3,0.9c-1.3,0.6-2.5,1.5-3.5,2.6c-1,1.1-1.8,2.4-2.4,3.9c-0.6,1.5-0.9,3.2-0.9,5v0.8c0,1.9,0.3,3.6,0.9,5.1
c0.6,1.5,1.4,2.8,2.4,3.9s2.2,1.9,3.5,2.5C16.4,47.4,17.9,47.7,19.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.5-0.8-6.2-2.3-8c-1.6-1.8-3.7-2.7-6.3-2.7c-3.2,0-5.6,1.1-7.4,3.3s-2.7,5.1-2.7,8.8
V51.8z"/>
</g>
</g>
</svg>
</div>
</div>
<!-- END PRELOADER -->
<!-- HEADER -->
<header class="header js-stick">
<div class="container">
<!-- YOUR LOGO HERE -->
<div class="inner-header">
<a class="inner-brand" href="index.html">
<img class="brand-light" src="assets/images/logo-light.png" width="100" alt="">
<img class="brand-dark" src="assets/images/logo-dark.png" width="100" alt="">
</a>
</div>
<!-- OPEN MOBILE MENU -->
<div class="main-nav-toggle">
<div class="nav-icon-toggle" data-toggle="collapse" data-target="#custom-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</div>
</div>
<!-- WIDGETS MENU -->
<div class="inner-header pull-right hide-me">
<div class="menu-extras clearfix">
<!-- SLACK LINK -->
<div class="menu-item">
<div class="">
<a href="slack-signup.html" target="_blank" id="" data-toggle="tooltip" title="" data-placement="bottom" data-original-title="Join us on Slack!">
<img src="assets/images/slack_icon.svg" width="18" height="18"/>
<span class=""></span>
</a>
</div>
</div>
<!-- STACK EXCHANGE LINK -->
<div class="menu-item">
<div class="">
<a href="https://bitcoin.stackexchange.com/questions/tagged/bcoin" target="_blank" id="" data-toggle="tooltip" title="" data-placement="bottom" data-original-title="Questions! Checkout Stack Exchange.">
<img src="assets/images/stack-exchange-icon.svg" width="18" height="18"/>
<span class=""></span>
</a>
</div>
</div>
<!-- GITHUB STUFF -->
<div class="menu-item">
<div class="">
<a href="https://github.com/bcoin-org/bcoin" target="_blank" id="" data-toggle="tooltip" title="" data-placement="bottom" data-original-title="Visit bcoin on GitHub to see the code!">
<img src="assets/images/github_icon.svg" width="18" height="18"/>
<span class=""></span>
</a>
</div>
</div>
<div class="menu-item">
<div class="ghbuttons">
<a class="github-button" href="https://github.com/bcoin-org/bcoin" data-icon="octicon-star" data-count-href="/bcoin-org/bcoin/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star bcoin-org/bcoin on GitHub">Star</a>
<a class="github-button" href="https://github.com/bcoin-org/bcoin/fork" data-icon="octicon-repo-forked" data-count-href="/bcoin-org/bcoin/network" data-show-count="true" data-count-aria-label="# forks on GitHub" aria-label="Fork bcoin-org/bcoin on GitHub">Fork</a>
</div>
</div>
</div>
</div>
<!-- MAIN MENU -->
<nav id="custom-collapse" class="main-nav collapse clearfix">
<ul class="inner-nav pull-right">
<!-- HOME -->
<li><a href="./index.html">Home</a></li>
<!-- END HOME -->
<!-- FEATURES -->
<li><a href="./index.html#features">What is Bcoin</a></li>
<!-- END FEATURES -->
<!-- GUIDES -->
<li><a href="guides.html">Guides</a></li>
<!-- GUIDES -->
<!-- API REFERENCE - newer, how to interact once you're setup -->
<li><a href="./api-docs/index.html">API Docs</a></li>
<!-- END API -->
<!-- FULL DOCS - older, full reference
<li><a href="http://bcoin.io/docs/index.html">Docs</a></li>-->
<!-- END DOCS -->
<!-- DIVIDER
<li><a>&nbsp;</a></li>
<li><a href="#">All Demos</a></li>-->
</ul>
</nav>
</div>
</header>
<!-- END HEADER -->
<!-- WRAPPER -->
<div class="wrapper">
<!-- PAGE TITLE -->
<section class="module-sm bg-white-dark" data-background="assets/images/bg-header.jpg">
<div class="container">
<div class="row">
<div class="col-sm-12 text-center">
<h2 class="montserrat text-uppercase m-b-10"><span class="text-highlight-black" style="line-height: 1.5;">&nbsp;Guides &nbsp;and &nbsp;Videos&nbsp;</span></h2>
</div>
</div>
</div>
</section>
<!-- END PAGE TITLE -->
<!-- GUIDES/TUTORIALS -->
<section class="module" style="padding-top:70px !important;">
<div class="container">
<div class="row">
<!-- SIDEBAR -->
<div class="col-sm-3 sidebar">
<!-- CATEGORIES WIDGET -->
<div class="widget guide-list">
<h6 class="montserrat text-uppercase bottom-line">Install</h6>
<ul class="icons-list">
<li><a href="guides/install-linux.html">Install on Linux</a></li>
<li><a href="guides/install-mac.html">Install on Mac OS</a></li>
<li><a href="guides/install-windows.html">Install on Windows</a></li>
<!--<li><a data-toggle="" href="">Quick Sync (Torrent) </a></li>-->
</ul>
<br>
<h6 class="montserrat text-uppercase bottom-line">Guides</h6>
<ul class="icons-list">
<li><a href="guides/generate-address.html">Generate A Bitcoin Address</a></li>
<li><a href="guides/scripting.html">Intro to Scripting</a></li>
<li><a href="guides/op_return.html">Create an OP_RETURN</a></li>
<!--<li><a data-toggle="" href="">Quick Sync (Torrent) </a></li>-->
</ul>
</div>
<!-- END CATEGORIES WIDGET -->
<!-- TEXT WIDGET -->
<div class="widget">
<h6 class="montserrat text-uppercase bottom-line">Looking for Docs?</h6>
<p>Checkout our <a href="../api-docs/index.html">API Docs</a> or the <a href="http://bcoin.io/docs/index.html">Full Documentation</a></p>
</div>
<!-- END TEXT WIDGET -->
<!-- TEXT WIDGET -->
<div class="widget">
<h6 class="montserrat text-uppercase bottom-line">Get Involved</h6>
<p>If you think you've got what it takes to make your own bcoin guides and tutorials, reach out to us on <a href="slack-signup.html"> Slack!</a></p>
<p>Want to join the team?<a href="https://angel.co/purse/jobs/90956-bitcoin-protocol-engineer-bcoin"> We’re hiring.</a></p>
</div>
<!-- END TEXT WIDGET -->
</div>
<!-- END SIDEBAR -->
<!-- NEW BLOG CONTENT -->
<div class="col-sm-9 blog-content post-thumbnail">
<div class="col-sm-1"></div>
<div class="col-sm-11 guide-section-title montserrat text-uppercase bottom-line2">OS Installs</div>
<!-- OS INSTALLS -->
<article class="post format-image">
<div class="row">
<div class="col-sm-1"></div>
<!-- images not used yet
<div class="col-sm-3">
<div class="post-preview">
<a href="#"><img src="assets/images/guides/get-started.png" alt=""></a>
</div>
</div> -->
<div class="col-sm-3 guide-block">
<a href="guides/install-linux.html">
<div class="os-install text-center" style="color:#000;">
<i class="fa fa-linux fa-4x"></i>
<h2 class="">Linux Install</h2>
</div>
</a>
</div>
<div class="col-sm-3 guide-block">
<a href="guides/install-mac.html">
<div class="os-install text-center" style="color:#000;">
<i class="fa fa-apple fa-4x"></i>
<h2 class="">Mac Install</h2>
</div>
</a>
</div>
<div class="col-sm-3 guide-block">
<a href="guides/install-windows.html">
<div class="os-install text-center" style="color:#000;">
<i class="fa fa-windows fa-4x"></i>
<h2 class="">Win Install</h2>
</div>
</a>
</div>
</div>
</article>
<!-- END POST IMAGE -->
<div class="col-sm-1"></div>
<div class="col-sm-11 guide-section-title montserrat text-uppercase bottom-line2">Guides</div>
<!-- GENERATE BITCOIN ADDRESS GUIDE -->
<article class="post format-image">
<div class="row">
<div class="col-sm-1"></div>
<!-- images not used yet
<div class="col-sm-3">
<div class="post-preview">
<a href="#"><img src="assets/images/guides/get-started.png" alt=""></a>
</div>
</div> -->
<div class="col-sm-10">
<div class="post-content" style="color:#000;">
<h2 class="post-title"><a href="guides/generate-address.html"><!--<i class="fa fa-linux"></i>-->Generate a Bitcoin Address</a></h2>
<ul class="post-meta">
<li>By Javed Khan</li>
</ul>
<p>Follow along with the steps to build a transaction from scratch using built-in bcoin utilities. These steps are based on those outlined in the <a href="https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses">Bitcoin Wiki</a>.</p>
<a href="guides/generate-address.html" class="btn btn-lg btn-link btn-base">Start ›</a>
</div>
</div>
</div>
</article>
<!-- INTRO TO SCRIPTING -->
<article class="post format-image">
<div class="row">
<div class="col-sm-1"></div>
<!-- images not used yet
<div class="col-sm-3">
<div class="post-preview">
<a href="#"><img src="assets/images/guides/get-started.png" alt=""></a>
</div>
</div> -->
<div class="col-sm-10">
<div class="post-content" style="color:#000;">
<h2 class="post-title"><a href="guides/scripting.html"><!--<i class="fa fa-linux"></i>-->Intro to Scripting</a></h2>
<ul class="post-meta">
<li>By JJ</li>
</ul>
<p>Scripts are array-like objects with some helper functions. Learn the basics here.</p>
<a href="guides/scripting.html" class="btn btn-lg btn-link btn-base">Start ›</a>
</div>
</div>
</div>
</article>
<!-- OP_RETURN -->
<article class="post format-image">
<div class="row">
<div class="col-sm-1"></div>
<!-- images not used yet
<div class="col-sm-3">
<div class="post-preview">
<a href="#"><img src="assets/images/guides/get-started.png" alt=""></a>
</div>
</div> -->
<div class="col-sm-10">
<div class="post-content" style="color:#000;">
<h2 class="post-title"><a href="guides/op_return.html"><!--<i class="fa fa-linux"></i>-->Create an OP_RETURN</a></h2>
<ul class="post-meta">
<li>By Javed Khan</li>
</ul>
<p>This example creates a transaction with output containing a null data script with our data.</p>
<a href="guides/op_return.html" class="btn btn-lg btn-link btn-base">Start ›</a>
</div>
</div>
</div>
</article>
<!-- END POST IMAGE -->
</div>
<!-- END BLOG CONTENT -->
</div><!-- .row -->
</div>
</section>
<!-- END NEW BLOGS -->
</div><!-- .row -->
</div>
</section>
<!-- END BLOGS -->
<!-- PARALLAX DOCS CTA -->
<section class="module bg-white-alfa-30 parallax color-white" data-background="assets/images/bg-header.jpg">
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="text-center">
<h2 class="montserrat text-uppercase m-b-30">Ready to start building? Read the docs!</h2>
<a href="./api-docs/index.html" target="_blank" class="btn btn-lg btn-purple">Documentation</a>
</div>
</div>
</div><!-- .row -->
</div>
</section>
<!-- END PARALLAX DOCS CTA -->
<!-- FOOTER -->
<footer id="footer" class="footer-minimal">
<div class="container">
<div class="row">
<div class="col-sm-12">
<ul class="social-icons social-icons-circle text-center m-b-35">
<li><a href="https://twitter.com/bcoin"><i class="fa fa-twitter"></i></a></li>
<li><a href="https://github.com/bcoin-org/bcoin"><i class="fa fa-github"></i></a></li>
<li><a href="slack-signup.html" target="_blank"><i class="fa fa-slack"></i></a></li>
</ul>
</div>
</div>
<div class="row">
<div class="col-sm-12 text-center m-b-35">
<img class="m-b-35 QR-code" src="assets/images/donation_QR.png"/>
<p class="m-0"><strong>Bcoin Development Donation Address:</strong><br />3Bi9H1hzCHWJoFEjc4xzVzEMywi35dyvsV</p>
</div>
</div>
<div class="row">
<div class="col-sm-12 text-center">
<p class="m-0">Copyright <a href="#">bcoin.io, Purse</a>, 2017, All Rights Reserved.</p>
</div>
</div>
</div>
</footer>
<!-- END FOOTER -->
</div>
<!-- /WRAPPER -->
<!-- JAVASCRIPT FILES -->
<script src="assets/js/jquery-2.2.3.min.js"></script>
<script src="http://maps.googleapis.com/maps/api/js?v=3"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/js/plugins.min.js"></script>
<script src="assets/js/stickyfill.min.js"></script>
<script src="assets/js/custom.min.js"></script>
<!-- github button js -->
<script async defer src="https://buttons.github.io/buttons.js"></script>
</body>
</html>s

5
page-templates/guides-sidebar.html

@ -3,18 +3,21 @@
<div class="widget guide-list">
<h6 class="montserrat text-uppercase bottom-line">Install</h6>
<ul class="icons-list">
<!-- INSTALL-LIST -->
<li><a href="install-linux.html">Install on Linux</a></li>
<li><a href="install-mac.html">Install on Mac OS</a></li>
<li><a href="install-windows.html">Install on Windows</a></li>
<!--<li><a data-toggle="" href="">Quick Sync (Torrent) </a></li>-->
<!-- /INSTALL-LIST -->
</ul>
<br>
<h6 class="montserrat text-uppercase bottom-line">Guides</h6>
<ul class="icons-list">
<!-- GUIDES-LIST -->
<li><a href="generate-address.html">Generate A Bitcoin Address</a></li>
<li><a href="scripting.html">Intro to Scripting</a></li>
<li><a href="op_return.html">Create an OP_RETURN</a></li>
<!--<li><a data-toggle="" href="">Quick Sync (Torrent) </a></li>-->
<!-- /GUIDES-LIST -->
</ul>
</div>
<!-- END CATEGORIES WIDGET -->

12
page-templates/guides-wrapper.html

@ -23,8 +23,8 @@
<div class="row">
<!-- SIDEBAR -->
<!-- END SIDEBAR -->
<!-- GUIDES-SIDEBAR -->
<!-- /GUIDES-SIDEBAR -->
<!-- START OF ARTICLE CONTAINER -->
<div class="col-sm-9 blog-content post-thumbnail">
@ -86,8 +86,10 @@
</section>
<!-- END PARALLAX DOCS CTA -->
<!-- FOOTER -->
<!-- END FOOTER -->
<!-- FOOTER-SECTION -->
<!-- /FOOTER-SECTION -->
</div>
<!-- /WRAPPER -->
<!-- /WRAPPER -->
<!-- FOOTER-SCRIPTS -->
<!-- /FOOTER-SCRIPTS -->

5
page-templates/page-wrapper.html

@ -66,6 +66,9 @@
</script>
</head>
<body>
<!-- HEADER-SECTION -->
<!-- /HEADER-SECTION -->
<!-- GUIDES-WRAPPER -->
<!-- /GUIDES-WRAPPER -->
</body>
</html>

42
sidebar-generator.js

@ -0,0 +1,42 @@
const marked = require('marked');
const fs = require('fs');
const path = require('path');
const getGuideTitles = function getGuideTitles() {
const markdownDir = path.resolve(__dirname, 'guides-markdown');
const titles = [];
const renderer = new marked.Renderer();
// Add text to list of titles if in a header level 1 or 2
renderer.heading = (text, level) => {
if (level == '2' || level == '1' ) {
titles.push(text);
}
}
marked.setOptions({
renderer,
gfm: true,
});
// Promisify the readdir so we can retrieve the titles
// when it's done
return new Promise((resolve, reject) => {
fs.readdir(markdownDir, (err, files) => {
if (err) reject(err);
for (let i=0; i < files.length; i++) {
const file = files[i];
const ext = path.extname(file);
if (ext === '.md') {
markdownFile = path.resolve(markdownDir, file);
const markdownString = fs.readFileSync(markdownFile, 'utf8');
marked(markdownString);
}
}
resolve(titles);
});
});
}
getGuideTitles().then(titles => console.log(titles));

101
utils/createHTML.js

@ -0,0 +1,101 @@
const marked = require('marked');
const fs = require('fs');
const path = require('path');
const Prism = require('prismjs');
const PrismLanguages = require('prism-languages');
const createHTML = async function createHTML(markdownFile, markdownDir, htmlFile, author, postMeta) {
/******
Prepare the marked renderer
******/
const guidesDir = path.resolve(__dirname, 'guides');
const templatesDir = path.resolve(__dirname, 'page-templates');
const renderer = new marked.Renderer();
let guideTitle, guideDescription;
// Custom renderer for code snippet highlighting
const getPostMeta = (author='bcoin-org') => '<ul class="post-meta">'
+ '<li class="author">By ' + author + '</li>'
+ '</ul>';
// Custom renderer for top two level headers
renderer.heading = (text, level) => {
if (level == '2' || level == '1' ) {
let header = '<h2 class="post-title panel-title">'
+ text + '</h2>';
if (author) {
postMeta = getPostMeta(author)
header += postMeta;
}
guideTitle = text;
return header;
} else {
return `<h${level}>${text}</h${level}>`;
}
}
renderer.code = function (code, language) {
if (language === 'post-author') {
// only return code block if wasn't set by argument
return postMeta ? '' : getPostMeta(code);
}
if (language === 'post-description') {
guideDescription = code;
return;
}
return `<pre class="line-numbers language-${language}">`
+ `<code class="line-numbers language-${language}">`
+ Prism.highlight(code, PrismLanguages[language])
+ '</code></pre>';
}
marked.setOptions({
renderer,
gfm: true,
});
const markdownString = fs.readFileSync(markdownFile, 'utf8');
// Assemble guide text container
let blogText = marked(markdownString);
// Get the guide html template and find start of guide section
// const pageWrapper = fs.readFileSync(path.resolve(templatesDir), 'page-wrapper.html').toString().split('\n');
// const header = fs.readFileSync(path.resolve(templatesDir), 'header.html').toString().split('\n');
// const guidesSidebar = fs.readFileSync(path.resolve(templatesDir), 'guides-sidebar.html').toString().split('\n');
// const guidesWrapper = fs.readFileSync(path.resolve(templatesDir), 'guide-wrapper.html').toString().split('\n');
// const footer = fs.readFileSync(path.resolve(templatesDir), 'footer.html').toString().split('\n');
const template = fs.readFileSync(path.resolve(markdownDir, 'guides-template.txt'))
.toString().split('\n');
// const startHeaderText = 'HEADER-SECTION';
// const startGuidesWrapper = 'GUIDES-WRAPPER';
// const startGuidesSidebar = 'GUIDES-SIDEBAR';
const startGuideText = 'START OF GUIDE'; // NOTE: Make sure to change this if the comment text changes
// const startFooter = 'FOOTER-SECTION';
// const startFooterScripts = 'FOOTER-SCRIPTS';
let startLine = 0;
// 1. insert post into guidesWrapper
// 2. insert
for (let i=0; i <= template.length; i++) {
if (template[i].indexOf(startGuideText) > -1) {
startLine = i + 1;
break;
}
}
template.splice(startLine, 0, blogText);
fs.writeFileSync(htmlFile, template.join('\n'));
console.log(`Finished ${path.basename(htmlFile)}`);
}
module.exports = createHTML;
Loading…
Cancel
Save