File tree Expand file tree Collapse file tree 3 files changed +11
-3
lines changed
Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -4,4 +4,5 @@ date: 2022-01-02T13:00:18-05:00
44images : []
55aliases :
66 - " /archive"
7+ - " /artifact"
78---
Original file line number Diff line number Diff line change 88 {
99 "from": {{ $absAlias | path.Clean | jsonify }},
1010 "to": {{ $page.RelPermalink | jsonify }},
11- "status": 301
11+ "status": 301,
12+ "kind": "static"
1213 },
1314 {
1415 "from": {{ $absAlias | path.Clean | printf "%s/" | jsonify }},
1516 "to": {{ $page.RelPermalink | jsonify }},
16- "status": 301
17+ "status": 301,
18+ "kind": {{ if (eq $page.Kind "page" "home") }}"static"{{ else }}"dynamic"{{ end }}
1719 },
1820 {{ end }}
1921{{ end }}
2426 "from": {{ $redirect.from | path.Clean | jsonify }},
2527 "to": {{ $redirect.to | jsonify }},
2628 "status": {{ $redirect.status | jsonify }},
29+ "kind": "static"
2730 }{{ if (eq $index (sub $numRedirects 1)) }},{{ end }}
2831{{ end }}
2932]
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ interface Redirect {
88 from : string ;
99 to : string ;
1010 status : number ;
11+ kind : "static" | "dynamic" ;
1112} ;
1213
1314type Redirects = ReadonlyArray < Redirect > ;
@@ -72,7 +73,10 @@ export default {
7273 const redirects : Redirects = await redirectsResponse . json ( ) ;
7374
7475 for ( const redirect of redirects ) {
75- if ( requestUrl . pathname === redirect . from ) {
76+ if (
77+ ( redirect . kind === "static" && requestUrl . pathname === redirect . from )
78+ || ( redirect . kind === "dynamic" && requestUrl . pathname . startsWith ( redirect . from ) )
79+ ) {
7680 const url = new URL ( request . url ) ;
7781 url . pathname = redirect . to ;
7882 return Response . redirect ( url . toString ( ) , redirect . status ) ;
You can’t perform that action at this time.
0 commit comments