@@ -117,79 +117,10 @@ if ($PSScriptRoot -and "$PSScriptRoot" -ne "$pwd") {
117117 Push-Location $psScriptRoot
118118}
119119
120- if ($site.includes .' LastBuild.json' -is [Management.Automation.ExternalScriptInfo ]) {
120+ if ($site.includes .' LastBuild.json' -is [Management.Automation.ExternalScriptInfo ]) {
121121 . $site.includes .' LastBuild.json' > ./ lastBuild.json
122122}
123123
124- # region index.rss
125- if (-not $Site.NoRss ) {
126- $pagesByDate = @ ($site.PagesByUrl.GetEnumerator () |
127- Sort-Object { $_.Value.Date } - Descending)
128- $lastPubDate = if ($pagesByDate.Values.Date ) {
129- $pagesByDate [0 ].Value.Date.ToString(' R' )
130- } else {
131- $lastBuildTime.ToString (' R' )
132- }
133- $rssXml = @ (
134- ' <rss version="2.0">'
135- ' <channel>'
136- " <title>$ ( [Security.SecurityElement ]::Escape($ (
137- if ($site.Title ) { $site.Title } else { $site.CNAME }
138- ))) </title>"
139- " <link>$ ( $site.RootUrl ) </link>"
140- " <description>$ ( [Security.SecurityElement ]::Escape($ (
141- if ($site.Description ) { $site.Description } else { $site.Title }
142- ))) </description>"
143- " <pubDate>$ ( $lastPubDate ) </pubDate>"
144- " <lastBuildDate>$ ( $lastBuildTime.ToString (' R' )) </lastBuildDate>"
145- " <language>$ ( [Security.SecurityElement ]::Escape($site.Language )) </language>"
146- :nextPage foreach ($keyValue in $pagesByDate ) {
147- $key = $keyValue.Key
148- $keyUri = $key -as [Uri ]
149- $page = $keyValue.Value
150- if ($site.Disallow ) {
151- foreach ($disallow in $site.Disallow ) {
152- if ($keyUri.LocalPath -like " *$disallow *" ) { continue nextPage }
153- if ($keyUri.AbsoluteUri -like " *$disallow *" ) { continue nextPage }
154- }
155- }
156- if ($site.PagesByUrl [$key ].NoIndex) { continue }
157- if ($site.PagesByUrl [$key ].NoSitemap) { continue }
158- if ($site.PagesByUrl [$key ].OutputFile.Extension -ne ' .html' ) { continue }
159- " <item>"
160- " <title>$ ( [Security.SecurityElement ]::Escape($ (
161- if ($page.Title ) { $page.Title }
162- elseif ($site.Title ) { $site.Title }
163- else { $site.CNAME }
164- ))) </title>"
165- if ($site.PagesByUrl [$key ].Date -is [DateTime ]) {
166- " <pubDate>$ ( $site.PagesByUrl [$key ].Date.ToString(' R' )) </pubDate>"
167- }
168- " <description>$ ( [Security.SecurityElement ]::Escape($ (
169- if ($page.Description ) { $page.Description }
170- elseif ($site.Description ) { $site.Description }
171- ))) </description>"
172- " <link>$key </link>"
173- " <guid isPermaLink='true'>$key </guid>"
174- " </item>"
175- }
176- ' </channel>'
177- ' </rss>'
178- ) -join ' ' -as [xml ]
179-
180- if ($rssXml ) {
181- $rssOutputPath = Join-Path $site.PSScriptRoot ' RSS' | Join-Path - ChildPath ' index.rss'
182- if (-not (Test-Path $rssOutputPath )) {
183- # Create the file if it doesn't exist
184- $null = New-Item - ItemType File - Force $rssOutputPath
185- }
186- $rssXml.Save ($rssOutputPath )
187- }
188- }
189-
190-
191- # endregion index.rss
192-
193124if ($site.includes .' Sitemap.xml' -is [Management.Automation.ExternalScriptInfo ]) {
194125 . $site.includes .' Sitemap.xml' > sitemap.xml
195126}
@@ -198,65 +129,15 @@ if ($site.includes.'Robots.txt' -is [Management.Automation.ExternalScriptInfo])
198129 . $site.includes .' Robots.txt' > robots.txt
199130}
200131
201- # region index.json
202- if (-not $Site.NoIndex ) {
203- $fileIndex =
204- if ($filePath ) { Get-ChildItem - Recurse - File - Path $FilePath }
205- else { Get-ChildItem - Recurse - File }
206-
207- $replacement =
208- if ($filePath ) {
209- " ^" + ([regex ]::Escape($filePath ) -replace ' \*' , ' .{0,}?' )
210- } else {
211- " ^" + [regex ]::Escape(" $pwd " )
212- }
132+ if ($site.includes .' Index.rss' -is [Management.Automation.ExternalScriptInfo ]) {
133+ New-Item - ItemType File - Path ./ RSS/ index.rss - Force - Value (
134+ . $site.includes .' Index.rss'
135+ )
136+ }
213137
214- $indexObject = [Ordered ]@ {}
215- $gitCommand = $ExecutionContext.SessionState.InvokeCommand.GetCommand (' git' , ' Application' )
216- foreach ($file in $fileIndex ) {
217- $gitDates =
218- try {
219- (& $gitCommand log -- follow -- format=% ci -- date default $file.FullName * > & 1 ) -as [datetime []]
220- } catch {
221- $null
222- }
223- $LASTEXITCODE = 0
224-
225- $indexObject [$file.FullName -replace $replacement ] = [Ordered ]@ {
226- Name = $file.Name
227- Length = $file.Length
228- Extension = $file.Extension
229- CreatedAt =
230- if ($gitDates ) {
231- $gitDates [-1 ]
232- } else {
233- $file.CreationTime
234- }
235- LastWriteTime =
236- if ($gitDates ) {
237- $gitDates [0 ]
238- } else {
239- $file.LastWriteTime
240- }
241- }
242- }
243-
244- foreach ($indexKey in $indexObject.Keys ) {
245- if (-not $indexObject [$indexKey ].CreatedAt) {
246- if ($indexObject [" $indexKey .ps1" ].CreatedAt) {
247- $indexObject [$indexKey ].CreatedAt = $indexObject [" $indexKey .ps1" ].CreatedAt
248- }
249- }
250- if (-not $indexObject [$indexKey ].LastWriteTime) {
251- if ($indexObject [" $indexKey .ps1" ].LastWriteTime) {
252- $indexObject [$indexKey ].LastWriteTime = $indexObject [" $indexKey .ps1" ].LastWriteTime
253- }
254- }
255- }
256-
257- $indexObject | ConvertTo-Json - Depth 4 > index.json
138+ if ($site.includes .' Index.json' -is [Management.Automation.ExternalScriptInfo ]) {
139+ . $site.includes .' Index.json' > index.json
258140}
259- # endregion index.json
260141
261142# region archive.zip
262143if ($site.Archive ) {
0 commit comments