diff --git a/website/README.md b/website/README.md
index 7d44459..0a085e2 100644
--- a/website/README.md
+++ b/website/README.md
@@ -3,7 +3,7 @@ The main website's pages are written in HTML & CSS whilst the doc pages are auto
** DO NOT MODIFY THE DOC PAGES IN THE [dist/docs/](dist/docs/) DIRECTORY! **
## Links in the md files in [src/](src/)
-Please note that you are required to use either a link relative to the root folder with double forward slash (example: *//server/app.js*), to the website root with a single forward slash (example: */download*), to the docs root with &/ (example: *&/setup*) or simply /docs/ (example: */docs/setup*), a full link (example: *https://libreevent.janishutz.com/docs*) or a relative link (example: *plugins/music*). If you do not follow these patterns, the website won't build or the links will not work correctly.
+Please note that you are required to use either a link relative to the root folder with double forward slash (example: *//server/app.js*), to the website root with a single forward slash (example: */download*), to the docs root with &/ (example: *&/setup*) or simply /docs/ (example: */docs/setup*), a full link (example: *https://libreevent.janishutz.com/docs*) or a relative link (example: *plugins/music*). Note that *../* relative links are NOT intended to be used and will lead to an error when building the docs! If you do not follow these patterns, the website won't build or the links will not work correctly.
***NOTE: Don't be confused if the root folder links don't work in the Markdown, as they use specific syntax for the build script.***
diff --git a/website/build.js b/website/build.js
index 855cbfb..c094fa2 100644
--- a/website/build.js
+++ b/website/build.js
@@ -14,16 +14,19 @@ const path = require( 'path' );
buildNav( buildDocs() );
+
function buildNav ( pathObject ) {
console.log( 'building nav ' + pathObject );
}
function buildDocs () {
+ let allFiles = [];
+
let directoriesToScan = [];
let files = fs.readdirSync( path.join( __dirname + '/src/' ) );
for ( let file in files ) {
if ( files[ file ].substring( files[ file ].length - 3 ) == '.md' ) {
- handleMD( files[ file ] );
+ allFiles.push( handleMD( path.join( __dirname + '/src/' + files[ file ] ) ) );
} else {
directoriesToScan.push( files[ file ] );
}
@@ -37,7 +40,7 @@ function buildDocs () {
count -= 1;
for ( let file in files ) {
if ( files[ file ].substring( files[ file ].length - 3 ) == '.md' ) {
- handleMD( files[ file ] );
+ allFiles.push( handleMD( path.join( __dirname + '/src/' + directoriesToScan[ missing ] + '/' + files[ file ] ) ) );
} else {
directoriesToScan.push( directoriesToScan[ missing ] + '/' + files[ file ] );
count += 1;
@@ -45,10 +48,81 @@ function buildDocs () {
}
}
}
- md2html.render( '#Test' );
- return 'Hi';
+ return allFiles;
}
-function handleMD ( path ) {
- console.log( 'md file', path );
+function handleMD ( filepath ) {
+ let fileContent = md2html.render( fs.readFileSync( filepath ).toString() );
+ for ( let letter in fileContent ) {
+ if ( fileContent[ letter ] == '<' ) {
+ if ( fileContent.slice( parseInt( letter ), parseInt( letter ) + 9 ) === '';
+ } else if ( link.slice( 0, 2 ) == '&/' ) {
+ newLink = '';
+ } else if ( link.slice( 0, 6 ) == '&/' ) {
+ newLink = '';
+ } else if ( link.slice( 0, 2 ) == '//' ) {
+ if ( link.includes( '.' ) ) {
+ newLink = '';
+ } else {
+ newLink = '';
+ }
+ } else {
+ console.error( 'Unsupported link: ' + link );
+ throw 'INVALID LINK FOUND IN PLUGINS README! Please fix and rerun the script';
+ }
+ fileContent = fileContent.slice( 0, parseInt( letter ) ) + newLink + fileContent.slice( parseInt( letter ) + i + 2, parseInt( fileContent.length ) );
+ }
+ }
+ }
+ return storeHTML( fileContent, filepath );
+}
+
+function storeHTML( html, filepath ) {
+ /*
+ TODO: Guess doc page title from first H1 Element.
+ */
+ let data = `
+
+
+ ${ filepath } :: DOCS - libreevent
+
+
+
+
+
+
+