Skip to content
This repository has been archived by the owner on Oct 27, 2022. It is now read-only.

Commit

Permalink
Running Prettier --Write to format all code
Browse files Browse the repository at this point in the history
  • Loading branch information
Reydescel Rodriguez committed Feb 27, 2021
1 parent a45fc49 commit 1d2b6b4
Show file tree
Hide file tree
Showing 13 changed files with 2,146 additions and 1,686 deletions.
8 changes: 7 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
{
"printWidth": 120,
"trailingComma": "es5",
"tabWidth": 4,
"semi": true,
"singleQuote": true
}
83 changes: 43 additions & 40 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
var showdown = require('showdown');
converter = new showdown.Converter({tables: 'true', simplifiedAutoLink: 'true'});
var showdown = require('showdown');
converter = new showdown.Converter({
tables: 'true',
simplifiedAutoLink: 'true',
});
// converter = converter.setOption('tables', 'true')
// converter = converter.setOption('simplifiedAutoLink','true');
var css = 'https://markdownpedia.tk/server/vital/style.css';
Expand All @@ -11,57 +14,57 @@ var template = fs.readFileSync('vital/template.html') + '';

var listofFiles = [];

fsExtra.emptyDirSync('site/html');
fsExtra.emptyDirSync('site/html');
var e404 = fs.readFileSync('vital/404.md') + '';
var html = converter.makeHtml(e404);
html = template.replace('{markdown}', html);
fs.writeFileSync('vital/404.html', html);
getfiles('site/markdown');
function getfiles(dir){
var files = fs.readdirSync(dir);
var i = 0;
while (i < files.length){
var now = getSecondPart(files[i]);
if (now == 'md'){
convert(files[i], dir);
getfiles('site/markdown');
function getfiles(dir) {
var files = fs.readdirSync(dir);
var i = 0;
while (i < files.length) {
var now = getSecondPart(files[i]);
if (now == 'md') {
convert(files[i], dir);
} else {
getfiles(dir + '/' + files[i]);
}
i++;
}
else{
getfiles(dir + '/' + files[i]);
}
i++;
}
}

var i = 0;
var text = '';
while (i < listofFiles.length){
var replaceText = listofFiles[i].replace('/', '');
if (replaceText == ''){
replaceText = 'home';
}
text += "<li><a href='#' onclick='window.location.pathname = \"" + listofFiles[i] + "\";'>" + replaceText + "</a></li>";
i ++;
while (i < listofFiles.length) {
var replaceText = listofFiles[i].replace('/', '');
if (replaceText == '') {
replaceText = 'home';
}
text +=
"<li><a href='#' onclick='window.location.pathname = \"" + listofFiles[i] + '";\'>' + replaceText + '</a></li>';
i++;
}

fs.writeFileSync('vital/pages/search/index.html',search.replace('{list}', text));
fs.writeFileSync('vital/pages/search/index.html', search.replace('{list}', text));

function convert(file, dir){
var filename = dir + '/' + file;
var content = converter.makeHtml(fs.readFileSync(filename) + '');
filename = filename.replace('site/markdown', 'site/html');
filename = filename.replace('.md', '.html');
var data = template.replace('{markdown}', content);
checkIfDir(dir.replace('site/markdown', 'site/html'));
fs.writeFileSync(filename, data);
listofFiles.push(dir.replace('site/markdown',''));
console.log('File is ' + file + ' and is in ' + dir);
function convert(file, dir) {
var filename = dir + '/' + file;
var content = converter.makeHtml(fs.readFileSync(filename) + '');
filename = filename.replace('site/markdown', 'site/html');
filename = filename.replace('.md', '.html');
var data = template.replace('{markdown}', content);
checkIfDir(dir.replace('site/markdown', 'site/html'));
fs.writeFileSync(filename, data);
listofFiles.push(dir.replace('site/markdown', ''));
console.log('File is ' + file + ' and is in ' + dir);
}
function getSecondPart(str) {
return str.split('.')[1];
return str.split('.')[1];
}

function checkIfDir(dir){
if (!fs.existsSync(dir)){
fs.mkdirSync(dir);
}
}
function checkIfDir(dir) {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
}
Loading

0 comments on commit 1d2b6b4

Please sign in to comment.