Stubbed homepage with links to other pages
This commit is contained in:
parent
cb854ff218
commit
0df66853e7
4 changed files with 49 additions and 10 deletions
|
@ -1,5 +1,6 @@
|
|||
const { join } = require('path');
|
||||
const { readdir, readJson } = require('fs-extra');
|
||||
const marked = require('marked');
|
||||
const requestGithub = require('./request');
|
||||
const schema = require('./schema');
|
||||
|
||||
|
@ -15,7 +16,12 @@ const getPinnedRepoJSONs = async () => {
|
|||
}
|
||||
}
|
||||
} = await requestGithub(schema);
|
||||
return pinnedRepoData.map(data => data.node);
|
||||
return pinnedRepoData.map(data => {
|
||||
if (data.node.readme && data.node.readme.text) {
|
||||
data.node.readme.html = marked(data.node.readme.text);
|
||||
}
|
||||
return data.node;
|
||||
});
|
||||
};
|
||||
|
||||
const getStaticPageJSONs = async () => {
|
||||
|
@ -35,7 +41,13 @@ const getStaticPageJSONs = async () => {
|
|||
});
|
||||
|
||||
try {
|
||||
return await Promise.all(readFilesPromises);
|
||||
let allData = await Promise.all(readFilesPromises);
|
||||
return allData.map(data => {
|
||||
if (data.readme && data.readme.text) {
|
||||
data.readme.html = marked(data.readme.text);
|
||||
}
|
||||
return data;
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error while reading JSON', error);
|
||||
return;
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
const { join } = require('path');
|
||||
const { outputFile } = require('fs-extra');
|
||||
const marked = require('marked');
|
||||
const getTemplate = require('./template');
|
||||
|
||||
const distPath = './dist';
|
||||
|
||||
const generateIndexPage = async jsonData => {
|
||||
console.log('Index page...TODO');
|
||||
const indexTemplate = await getTemplate('index');
|
||||
|
||||
try {
|
||||
return outputFile(join(distPath, 'index') + '.html', indexTemplate(jsonData));
|
||||
} catch (error) {
|
||||
console.error('Error while writing index html file', error);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
const generateInteriorPages = async jsonData => {
|
||||
const interiorTemplate = await getTemplate('interior');
|
||||
const saveAsInteriorHTML = async json => {
|
||||
let fileName = json.name.replace(/[^a-zA-Z\d:]/g, '').toLowerCase();
|
||||
if (json.readme && json.readme.text) {
|
||||
json.readme.html = marked(json.readme.text);
|
||||
}
|
||||
return outputFile(join(distPath, fileName) + '.html', interiorTemplate(json));
|
||||
return outputFile(join(distPath, json.name) + '.html', interiorTemplate(json));
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
{
|
||||
"name": "Example"
|
||||
"name": "Example",
|
||||
"readme": {
|
||||
"text": "## Whats Up?"
|
||||
}
|
||||
}
|
||||
|
|
22
src/templates/index.hbs
Normal file
22
src/templates/index.hbs
Normal file
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Wroten - Portfolio</title>
|
||||
|
||||
<link href="./assets/stylesheet.css" rel="stylesheet" type="text/css">
|
||||
<link href="https://fonts.googleapis.com/css?family=Slabo+27px|Source+Code+Pro|Source+Sans+Pro:300" rel="stylesheet">
|
||||
|
||||
<meta charset="UTF-8">
|
||||
<meta name="author" content="Joe Wroten">
|
||||
<meta name="description" content="Web engineer realizing the best tools to communicate valuable information to the people who need it.">
|
||||
<meta name="keywords" content="developer,designer,engineer,web,portfolio">
|
||||
<meta name="viewport" content="width=device-width; height=device-height; maximum-scale=1.4; initial-scale=1.0; user-scalable=yes">
|
||||
</head>
|
||||
<body>
|
||||
<ol>
|
||||
{{#each this}}
|
||||
<li><a href="./{{this.name}}.html">{{this.name}}</a>
|
||||
{{/each}}
|
||||
</ol>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Reference in a new issue