forked from cadence/breezewiki
		
	Add types to Link header
This commit is contained in:
		
							parent
							
								
									cea9d2082b
								
							
						
					
					
						commit
						565d0a439a
					
				
					 1 changed files with 12 additions and 8 deletions
				
			
		|  | @ -21,13 +21,17 @@ | ||||||
|                                          (build-path path-static path-or-filename)))) |                                          (build-path path-static path-or-filename)))) | ||||||
|   (format "/static/~a?t=~a" (file-name-from-path the-path) (hash-ref static-data the-path))) |   (format "/static/~a?t=~a" (file-name-from-path the-path) (hash-ref static-data the-path))) | ||||||
| 
 | 
 | ||||||
|  | ; https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/preload | ||||||
| (: link-header String) | (: link-header String) | ||||||
| (define link-header | (define link-header | ||||||
|   (let* ([with-t '("main.css")] |   (let* ([with-t '(("main.css" "as=style"))] | ||||||
|          [with-t-full (map get-static-url with-t)] |          [without-t '(("preact.js" "as=script") | ||||||
|          [without-t '("preact.js" "source-sans-pro-v21-vietnamese_latin-ext_latin_greek-ext_greek_cyrillic-ext_cyrillic-regular.woff2")] |                       ("source-sans-pro-v21-vietnamese_latin-ext_latin_greek-ext_greek_cyrillic-ext_cyrillic-regular.woff2" "as=font" "crossorigin" "type=font/woff2"))] | ||||||
|          [without-t-full (map (λ (path) (format "/static/~a" path)) without-t)]) |          [with-t-full (map (λ ([path : (Listof String)]) (cons (get-static-url (car path)) (cdr path))) with-t)] | ||||||
|     (string-join |          [without-t-full (map (λ ([path : (Listof String)]) (cons (format "/static/~a" (car path)) (cdr path))) without-t)] | ||||||
|      (for/list : (Listof String) ([full-path : String (append with-t-full without-t-full)]) |          [all (append with-t-full without-t-full)] | ||||||
|        (format "<~a>; rel=\"preload\"" full-path)) |          [header-parts | ||||||
|      ", "))) |           (for/list : (Listof String) ([full-path all]) | ||||||
|  |             (define attributes (map (λ ([s : String]) (format "; ~a" s)) (cdr full-path))) | ||||||
|  |             (format "<~a>; rel=preload~a" (car full-path) (string-join attributes "")))]) | ||||||
|  |     (string-join header-parts ", "))) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue