@@ -109,17 +109,17 @@ Content here
109
109
}
110
110
111
111
task importImages {
112
- if ($IsLinux -eq $true ) {
112
+ if ($IsLinux -eq $true ) {
113
113
$screenshotdir = Get-Item ~/ Pictures
114
114
$prefixToRemove = ' Screenshot from '
115
115
}
116
- elseif ($IsWindows -eq $true ) {
116
+ elseif ($IsWindows -eq $true ) {
117
117
$screenshotdir = Get-Item ~/ OneDrive/ Pictures/ Screenshots
118
118
$prefixToRemove = ' Skärmbild '
119
119
}
120
- if ($screenshotdir -ne $null ) {
120
+ if ($screenshotdir -ne $null ) {
121
121
Get-ChildItem $screenshotdir | Where-Object { $_.LastWriteTime -gt (Get-Date ).AddMinutes(- $cutoffMinutes ) } | ForEach-Object {
122
- $newname = $_.Name.Replace ($prefixToRemove , ' ' ).Replace(' ' , ' -' ).ToLower()
122
+ $newname = $_.Name.Replace ($prefixToRemove , ' ' ).Replace(' ' , ' -' ).ToLower()
123
123
Write-Host " Copying $ ( $_.FullName ) to $rootdir /docs/assets/$newname "
124
124
Copy-Item $_.FullName " $rootdir /docs/assets/$newname "
125
125
}
@@ -128,5 +128,39 @@ task importImages {
128
128
Write-Host " Couldn't import any screenshots, check the path [$screenshotdir ]"
129
129
}
130
130
}
131
+
132
+ task posttags {
133
+ push-location $rootdir / docs
134
+ Remove-Item tags - Recurse - ErrorAction SilentlyContinue | Out-Null
135
+ New-Item tags - ItemType Directory | Out-Null
136
+ $frontMatterPattern = ' (?ms)^---\s*\r?\n(.*?)\r?\n---\s*\r?\n'
137
+
138
+ $alltags = @ ()
139
+ foreach ($file in gci _posts) {
140
+ $content = Get-Content $file - raw
141
+ if ($content -match $frontMatterPattern ) {
142
+ foreach ($line in $matches [1 ] -split [System.Environment ]::NewLine) {
143
+ $line -split ' :' , 2 | % {
144
+ $parts = $line -split ' :' , 2
145
+ if ($parts.Count -eq 2 ) {
146
+ $key = $parts [0 ].Trim()
147
+ if ($key -eq ' tags' ) {
148
+ $value = $parts [1 ].Trim() -split ' '
149
+ $alltags += $value.ToLower ()
150
+ }
151
+ }
152
+ }
153
+ }
154
+ }
155
+ }
156
+ $alltags = $alltags | Sort-Object - Unique
157
+ Write-Host " All tags: "
158
+ Write-Host $alltags
159
+ $alltags | Sort-Object - Unique | % {
160
+ " ---`n layout: tags`n tag-name: $_ `n ---" | Out-File - Path " tags/$_ .md"
161
+ }
162
+
163
+ }
164
+ task generateTags posttags
131
165
task copyImages importImages
132
- task . proofread, serve, surf
166
+ task . proofread, generateTags , serve, surf
0 commit comments