Skip to content

Instantly share code, notes, and snippets.

@tbeseda
Created October 27, 2010 20:37
Show Gist options
  • Select an option

  • Save tbeseda/649921 to your computer and use it in GitHub Desktop.

Select an option

Save tbeseda/649921 to your computer and use it in GitHub Desktop.
Google App Script incrementPage creates a new subpage of a specified page that has a title of the next increment
function incrementPage(parentURL, pageHTML) {
var parentPage = SitesApp.getPageByUrl(parentURL)
,childPages = parentPage.getAllDescendants()
,biggest = 1000;
for(i=0; i<childPages.length; i++) {
var currentName = childPages[i].getName();
if(isNaN(currentName))
continue;
+currentName; // make it a number
if(currentName > biggest)
biggest = currentName;
}
biggest++;
var newPage = parentPage.createWebPage(biggest, biggest, pageHTML);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment