forked from fediversity/fediversity
		
	extract file processing
This commit is contained in:
		
							parent
							
								
									0fbcedbd1a
								
							
						
					
					
						commit
						4d48c552c8
					
				
					 1 changed files with 17 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -23,17 +23,24 @@ rec {
 | 
			
		|||
      cmark ${builtins.toFile "${name}.md" markdown} > $out
 | 
			
		||||
    '';
 | 
			
		||||
 | 
			
		||||
  files = dir: lib.mapAttrs'
 | 
			
		||||
  /**
 | 
			
		||||
    Get documents from a flat directory of files
 | 
			
		||||
  */
 | 
			
		||||
  documents = dir: lib.mapAttrs'
 | 
			
		||||
    (
 | 
			
		||||
      attrname: value:
 | 
			
		||||
        let
 | 
			
		||||
          document = import (dir + "/${attrname}");
 | 
			
		||||
          name = lib.removeSuffix ".nix" attrname;
 | 
			
		||||
        in
 | 
			
		||||
        {
 | 
			
		||||
          name = "${name}.html";
 | 
			
		||||
          value = html document "${name}.html";
 | 
			
		||||
        }
 | 
			
		||||
      attrname: value: {
 | 
			
		||||
        name = lib.removeSuffix ".nix" attrname;
 | 
			
		||||
        value = import (dir + "/${attrname}");
 | 
			
		||||
      }
 | 
			
		||||
    )
 | 
			
		||||
    (builtins.readDir dir);
 | 
			
		||||
 | 
			
		||||
  files = dir: lib.mapAttrs'
 | 
			
		||||
    (
 | 
			
		||||
      name: document: {
 | 
			
		||||
        name = document.outPath;
 | 
			
		||||
        value = html document "${name}.html";
 | 
			
		||||
      }
 | 
			
		||||
    )
 | 
			
		||||
    (documents dir);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue