-
Notifications
You must be signed in to change notification settings - Fork 122
/
redirect.ps1
81 lines (42 loc) · 1.05 KB
/
redirect.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
$a = get-childitem .\rd
$b = $a.pschildname -split ('\.') -ne 'yml'
$rdname = $b |select-string -pattern '[a-z]\-[a-z]'
# first-last
#$urlname = $rdname -Replace("-",".")
$redirectfile = "redirect.json"
$header = @"
{
"redirections": [
"@
$footer = @"
]
}
"@
New-Item -path . -name $redirectfile -itemtype "file" -force
add-content -path $redirectfile -value $header
foreach($i in $rdname) {
$urlname = $i -replace("-",".")
$content = @"
{
"source_path": "rd/$urlname.md",
"redirect_url": "/$i",
"redirect_document_id": false
}
"@
add-content -path $redirectfile -value $content
add-content -path $redirectfile -value ","
}
<#
ForEach($content in $name) {
$content = @"
{
"source_path": "rd/$urlname.md",
"redirect_url": "/rd/$name",
"redirect_document_id": false
}
"@
write-host "Write"
add-content -path $redirectfile -value $content
add-content -path $redirectfile -value ","
} #>
add-content -path $redirectfile -value $footer