asset: Filter out assets that do not pass the site file filter.
* haunt/asset.scm (directory-assets): Add 'keep?' argument. (static-directory): Use site file filter.
This commit is contained in:
parent
568b9b8be6
commit
f5f24c57ce
|
@ -55,9 +55,9 @@ PREFIX."
|
|||
(mkdir-p (dirname target*))
|
||||
(copy-file source target*)))))
|
||||
|
||||
(define (directory-assets directory dest)
|
||||
(define (directory-assets directory keep? dest)
|
||||
"Create a list of asset objects to be stored within DEST for all
|
||||
files in DIRECTORY, recursively."
|
||||
files in DIRECTORY that match KEEP?, recursively."
|
||||
(define enter? (const #t))
|
||||
|
||||
;; In order to do accurate file name manipulation, every file name
|
||||
|
@ -67,10 +67,12 @@ files in DIRECTORY, recursively."
|
|||
(let ((base-length (length (file-name-components directory)))
|
||||
(dest* (file-name-components dest)))
|
||||
(lambda (file-name stat memo)
|
||||
(let* ((file-name* (file-name-components file-name))
|
||||
(target (join-file-name-components
|
||||
(append dest* (drop file-name* base-length)))))
|
||||
(cons (make-asset file-name target) memo)))))
|
||||
(if (keep? file-name)
|
||||
(let* ((file-name* (file-name-components file-name))
|
||||
(target (join-file-name-components
|
||||
(append dest* (drop file-name* base-length)))))
|
||||
(cons (make-asset file-name target) memo))
|
||||
memo))))
|
||||
|
||||
(define (noop file-name stat memo) memo)
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#:use-module (ice-9 ftw)
|
||||
#:use-module (ice-9 match)
|
||||
#:use-module (haunt asset)
|
||||
#:use-module (haunt site)
|
||||
#:export (static-directory))
|
||||
|
||||
(define* (static-directory directory #:optional (dest directory))
|
||||
|
@ -35,5 +36,5 @@
|
|||
in DIRECTORY, a file names relative to a site's source directory, and
|
||||
copies them into DEST, a prefix relative to a site's target output
|
||||
directory. By default, DEST is DIRECTORY."
|
||||
(lambda _
|
||||
(directory-assets directory dest)))
|
||||
(lambda (site posts)
|
||||
(directory-assets directory (site-file-filter site) dest)))
|
||||
|
|
Loading…
Reference in New Issue