Created
August 27, 2015 18:50
-
-
Save cfjedimaster/47fd99449959b30ca2d4 to your computer and use it in GitHub Desktop.
POC for generating dynamic paths for HarpJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The name of the file could be app.js, which could be a requirement. Maybe there could be multiple things it does besides just virtual paths and stuff. | |
*/ | |
//public is a copy of the Harp global data, basically everything you normally get access to | |
function generatePaths(public) { | |
//result must be an array | |
var result = []; | |
//lets make categories, pretend public.categories is an array of labels | |
for(var i=0; i<public.categories.length; i++) { | |
var newPage = {}; | |
//path is required. can be html, xml, etc | |
newPage.path = "/categories/"+public.categories[i]+".html"; | |
//body is required | |
//maybe if this is run via Node we can do a filesync read? | |
newPage.body = "<p>This is for category "+public.categories[i]+"</p>"; | |
result.push(newPage); | |
} | |
//lets make some random other page | |
var someOther = {path:"/virtual/something.html", body:"<h1>Hello World</h1>"}; | |
result.push(someOther); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment