vaderjs 1.4.1-hyiuy47 → 1.4.1-lv56aadeg5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,71 +48,43 @@ let server = http.createServer((req, res) => {
48
48
  });
49
49
 
50
50
  const generateHTML = (routeData) => {
51
+ console
51
52
 
52
- let { path, file, isParam, params, query, pathname } = routeData;
53
+ let { path, file, isParam, params,kind, isCatchAll, query, pathname } = routeData;
54
+ console.log(path, file, isParam, isCatchAll, query, pathname)
53
55
  let baseFolder = file.split('/').filter(f => f !== 'dist').join('/')
54
56
  if (file.includes('./dist')) {
55
57
  baseFolder = file.split('./dist')[1]
56
58
  }
57
-
58
- let isCatchAll = false;
59
+
59
60
 
60
61
  let html = `
61
62
  <!DOCTYPE html>
62
63
  <html>
63
64
  <head>
64
65
 
65
- <title>Vaderjs v1.3.3</title>
66
- <meta name="description" content="Vader.js is a modern web framework for building web applications.">
67
- <link rel="shortcut icon" href="https://raw.githubusercontent.com/Postr-Inc/Vader.js/main/logo.png" type="image/x-icon">
68
- </head>
69
- <body>
70
- <script id="v">
66
+ <title>Vaderjs v1.3.3</title>
67
+ <script id="v">
71
68
  window.$SERVER = true
72
69
  </script>
70
+ </head>
71
+ <body>
72
+
73
73
  <div id="app"></div>
74
74
  <script id="router" type="module">
75
75
  import Router from '/router.js'
76
76
 
77
77
  const rt = new Router
78
- ${Array.isArray(params)
79
- ? params
80
- .map((param) => {
81
- if (!param.jsFile) return "";
82
- let ranName = Math.random()
83
- .toString(36)
84
- .substring(7)
85
- .replace(".", "");
86
- let pd = Object.keys(param.paramData)[0];
87
- let baseFolder = path
88
- .split("/")
89
- .filter((f) => f !== "pages")
90
- .join("/");
91
-
92
- if(pd === '$catchall'){
93
- isCatchAll = true;
94
- console.log('catchall')
95
- return `
96
- import c${ranName} from '${param.jsFile}'
97
- rt.get($SERVER ? '/' : '/${baseFolder}/*', c${ranName})
98
- `
99
- }
78
+ ${Object.keys(routeData.params).length > 0 ? Object.keys(routeData.params).map((param, i) => {
79
+ return `rt.get('/${pathname}/:${param}', ' ${baseFolder}')`
80
+ }): ''}
100
81
 
101
- return `
102
-
103
- import c${ranName} from '${param.jsFile}'
104
- rt.get('/${baseFolder}/:${pd}', c${ranName})
105
- `;
106
- })
107
- .join("")
108
- : ""
109
- }
110
82
  let c = await import('${baseFolder}')
111
83
  if(Object.keys(c).includes('$prerender') && c.$prerender === false){
112
84
  document.head.setAttribute('prerender', 'false')
113
85
  }
114
86
  ${
115
- !isCatchAll ? `rt.get($SERVER? '/' : '${pathname}', c)` : ``
87
+ !isCatchAll ? `rt.get($SERVER? '/' : '${pathname}', c)` : `rt.get($SERVER? '/' : '${pathname}/*', c)`
116
88
  }
117
89
 
118
90
  rt.listen()
@@ -130,6 +102,9 @@ const generateHTML = (routeData) => {
130
102
  const ssg = async (config) => {
131
103
  return new Promise(async (resolve, reject) => {
132
104
  let { pages, output } = config;
105
+ if(!fs.existsSync(`${process.cwd()}/_dev/meta/routes.json`)){
106
+ process.exit()
107
+ }
133
108
  let routes = JSON.parse(fs.readFileSync(`${process.cwd()}/_dev/meta/routes.json`).toString())
134
109
  for (var i in routes) {
135
110
  let route = routes[i];
@@ -152,8 +127,7 @@ const ssg = async (config) => {
152
127
  document.querySelector("#app").innerHTML = "";
153
128
  }
154
129
  });
155
- let content = await page.content();
156
- console.log(`Writing ${routes[i].path} to ${output}/${routes[i].path}/index.html`)
130
+ let content = await page.content();
157
131
  if (output.includes('./dist')) {
158
132
  output = output.split('./dist')[1]
159
133
  }
@@ -171,19 +145,19 @@ const ssg = async (config) => {
171
145
  }
172
146
  })
173
147
  }
174
-
175
- if(context){
176
- server.listen(8700);
177
- await ssg({ pages: './pages', output: './dist' })
148
+
149
+ if(context){
150
+ server.listen(8700);
151
+ await ssg({ pages: './pages', output: './dist' })
178
152
  }
179
-
180
153
 
181
154
  export default {
182
155
  name: 'Vaderjs Static Site Generator',
183
156
  version: '1.0.0',
184
157
  useRuntime: 'node',
185
158
  entryPoint: process.cwd() + '/node_modules/vaderjs/@integrations/ssg.js',
186
- on: ['build', 'dev:change'],
159
+ on: ['build', 'dev'],
187
160
  }
188
161
 
189
162
 
163
+ // Path:integrations/ssg.js
package/README.md CHANGED
@@ -33,7 +33,7 @@ Tip: Each folder can be deep nested up to 4 levels!
33
33
  /pages/index.jsx = /
34
34
  /pages/home/[page].jsx = /home/:page
35
35
  /pages/path/index.jsx = /path/
36
- /pages/test/[...]/index.jsx = /path/test/*
36
+ /pages/test/[[...catchall]]/index.jsx = /path/test/*
37
37
  /pages/route/[param1]/[param2].jsx = /path/route/:param1/:param2
38
38
  ```
39
39
  Keyword folders - all files are passed from these folders to the `dist` folder
@@ -80,7 +80,7 @@ vader's compiler automatically handles routing so you wont need to! - it uses a
80
80
  /pages/index.jsx = /
81
81
  /pages/home/[page].jsx = /home/:page
82
82
  /pages/path/index.jsx = /path/
83
- /pages/path/[...].jsx = /path/*
83
+ /pages/path/[[...catchall]].jsx = /path/*
84
84
 
85
85
  ```
86
86
  For pages that have [params] you can derive it using this.request
@@ -163,7 +163,7 @@ Vaderjs has two types of in javascript styling - css modules and inline jsx styl
163
163
  ```jsx
164
164
 
165
165
  // inline
166
- <button style={{color:'red'}}>Button</button>
166
+ <button style={{color:'red', "@mobile":{color:'green'}}}>Button</button>
167
167
 
168
168
  // css module
169
169
 
@@ -203,12 +203,12 @@ export default class MyApp extends Component{
203
203
  console.log(ref.current) // p tag
204
204
  }, this)
205
205
  return <>
206
- <p ref={ref}>Count is {count}</p>
206
+ <p ref={ref}>Count is {count()}</p>
207
207
  {/**
208
208
  pass anything used from the toplevel render to the lowerlevel function params to be able to invoke!
209
209
  **/}
210
210
  <button onclick={()=>{
211
- setCount(++count)
211
+ setCount(count() + 1)
212
212
  }}>Increment</button>
213
213
  </>
214
214