1
0

3 Commits e6de9f3bab ... 04df9cf180

Autor SHA1 Nachricht Datum
  Lee Morgan 04df9cf180 Bug fix: Deleting previous temp files was failing. vor 3 Tagen
  Lee Morgan 1739370e34 Change the main tags for neovan files. vor 3 Tagen
  Lee Morgan c9665a5e69 Add file type explanations to readme. vor 4 Tagen
3 geänderte Dateien mit 40 neuen und 6 gelöschten Zeilen
  1. 34 0
      README.md
  2. 1 1
      index.js
  3. 5 5
      parseComponent.js

+ 34 - 0
README.md

@@ -22,6 +22,40 @@ const app = await neovan(express, options);
 
 app.listen(8000);
 ```
+### File Structure
+With NeoVan, any directory with your `routes` directory that has an index file will be considered a route. You can either use `index.html` or `index.neovan`. Either of these files will create a GET route for that directory. You can mix and match these as you pleasewithin your routes so long as each route contains only one index file.
+
+#### index.html
+When using and `index.html` file then you can write this just as you would a standard HTML file. For CSS and JavaScript you have two different options. First, you can write your CSS and JavaScript directly in the HTML with style/script tags as you normally would. Also, you can create index.css and/or index.js files. These files will be automatically bundled with the HTML. Also, you are free to use import statements within both JS and CSS and it will bundle those imports together. All import routes are relative. You may mix and match index files and embedded CSS/JavaScript as you please, but I would recommend using one or the other.
+
+#### index.neovan
+The recommended option is to use `index.neovan`, since it is simpler for componentization. In this case, you will fit HTML/CSS/JS in a single file. CSS is contained in `<style></style>` and JavaScript is contained in `<script></script>`. Anything not included in one of these two tags will be considered HTML.
+
+```html
+<script>
+    document.body.querySelector("h1").style.color = "white";
+</script>
+
+<!DOCTYPE html>
+<html lang="en">
+    <head>
+        <meta charset="utf-8">
+        <title>Example Page</title>
+    </head>
+    <body>
+        <h1>I am an example page</h1>
+    </body>
+</html>
+
+<style>
+    body{
+        background: black;
+    }
+</style>
+```
+
+## Components
+
 ## Environments
 
 ### Production

+ 1 - 1
index.js

@@ -75,7 +75,7 @@ const removeOldTmpDirs = async ()=>{
     const entries = await fs.readdir(os.tmpdir());
     for(let i = 0; i < entries.length; i++){
         if(entries[i].startsWith("neovan-")){
-            fs.rm(entries[i].name, {recursive: true, force: true});
+            fs.rm(entries[i], {recursive: true, force: true});
         }
     }
 }

+ 5 - 5
parseComponent.js

@@ -22,16 +22,16 @@ const getNeovanData = async (index)=>{
     const neovan = await fs.readFile(index, "utf-8");
     const parentPath = path.dirname(index);
     
-    const html = neovan.slice(neovan.indexOf("<contents>") + 10, neovan.indexOf("</contents>"));
+    const html = neovan.slice(neovan.indexOf("<@html>") + 11, neovan.indexOf("<@/html>"));
     let css = "";
     let js = "";
-    const cssIndex = neovan.indexOf("<style>");
+    const cssIndex = neovan.indexOf("<@style>");
     if(cssIndex >= 0){
-        css = neovan.slice(cssIndex + 7, neovan.indexOf("</style>"));
+        css = neovan.slice(cssIndex + 8, neovan.indexOf("<@/style>"));
     }
-    const jsIndex = neovan.indexOf("<script>")
+    const jsIndex = neovan.indexOf("<@script>")
     if(jsIndex >= 0){
-        js = neovan.slice(jsIndex + 8, neovan.indexOf("</script>"));
+        js = neovan.slice(jsIndex + 9, neovan.indexOf("<@/script>"));
     }
 
     const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "neovan-"));