2020-11-08 20:01:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								"use strict" ;  
						 
					
						
							
								
									
										
										
										
											2015-01-21 23:18:23 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// http://ruhoh.com/docs/2/pages/#toc_41
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/ *  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  If  a  page  has  a  permalink ,  that  permalink  should  be  respected . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  Otherwise  it  should  use  the  the  permalink  for  that  collection . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								* /  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:01:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								var  tags ,  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  permalinkTransforms , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  cases , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  path  =  /*exports.path ||*/  require ( "path" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-21 23:18:23 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								tags  =  {  
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:01:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								  year :  "Year from the page’  , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								  month :  "Month from the page’  , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								  day :  "Day from the page’  , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  path :  "The page file's path relative to the base of your website." , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  relative _path :  "The page file's path relative to its name-spaced directory." , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  filename :  "The page file's filename (path is not included)." , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  categories : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    "The specified categories for this page. If more than one category is set, only the first one is used. If no categories exist, the URL omits this parameter." , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								  i _month :  "Month from the page’  , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								  i _day :  "Day from the page’  , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  title :  "The title, as a slug." , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  slug :  "alias of title" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  name :  "alias of title" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  collection :  "i.e. posts/ or essays/ or whatever/" , 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-21 23:18:23 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								function  pad ( str ,  n )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  str  =  str . toString ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  if  ( str . length  <  n )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:01:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    str  =  "0"  +  str ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-21 23:18:23 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  return  str ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.youtube.com/watch?v=1NryFD9_hR0&list=RDOeLUK4a6Ojc&index=2
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								cases  =  {  
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:01:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								  "/:title.html" :  "/my-title.html" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  ":title/" :  "/my-title/" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  "/:bad/:title/" :  "/:bad/my-title/" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  "/:slug/" :  "/my-title/" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  "/:path/:name.html" :  "/posts/fun/my-title.html" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  "/:relative_path/:name/" :  "/fun/my-title/" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  "/:year-:month-:day/:name" :  "/2015-07-04/my-title/" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  "/:year/:i_month/:i_day/:name" :  "/2015/7/4/my-title/" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  "/:filename.html" :  "/my-file-name.html" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  "/:filename" :  "/my-file-name/" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  "/:filename/" :  "/my-file-name/" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  "/:collection/:title/" :  "/posts/my-title/" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  "/:collection/:filename" :  "/posts/my-file-name/" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  "/:something/:or/:other" :  "/:something/:or/:other/" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  "/:categories/:title/" :  "/desi/my-title/" , 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-21 23:18:23 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Object . keys ( cases ) . forEach ( function  ( tpl )  {  
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:01:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								  var  entity ,  tpld ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-21 23:18:23 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  entity  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:01:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    year :  "2015" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    month :  "07" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    day :  "04" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    title :  "My Title" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    slug :  "my-title" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    name :  "My-File-Name.html" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    relativePath :  "posts/fun" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    path :  "posts/fun/My-File-Name.html" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    collection :  "posts" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    yml :  {  categories :  [ "desi" ]  } , 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-21 23:18:23 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  tpld  =  permalinker ( tpl ,  entity ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  if  ( cases [ tpl ]  !==  tpld )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:01:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    console . error ( "[ERROR]" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    console . error ( tpl  +  " "  +  tpld  +  " "  +  cases [ tpl ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-21 23:18:23 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    throw  new  Error ( 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:01:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      "Did not template permalink correctly. "  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        tpl  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        " "  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        tpld  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        " "  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        cases [ tpl ] 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-21 23:18:23 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								} ) ;