@@ -68,6 +68,7 @@ Function Get-BloggerPost {
6868 if ($null -eq $result ) {
6969 throw " No post found with PostId '$PostId ' in blog '$BlogId '."
7070 }
71+ Write-Verbose " Post: $ ( $result | ConvertTo-Json - Depth 10 ) "
7172
7273 # Construct a subfolder based on the published date
7374 if ($FolderDateFormat -and $result.published ) {
@@ -80,12 +81,14 @@ Function Get-BloggerPost {
8081 # Ensure the output directory exists
8182 if (! (Test-Path - Path $OutDirectory )) {
8283 try {
84+ Write-Verbose " Creating output directory: $OutDirectory "
8385 New-Item - ItemType Directory - Path $OutDirectory - Force | Out-Null
8486 }
8587 catch {
8688 throw " Failed to create output directory '$OutDirectory ': $ ( $_.Exception.Message ) "
8789 }
8890 }
91+ Write-Verbose " Using output directory: $OutDirectory "
8992
9093 # Extract the HTML content
9194 $htmlContent = $result.content
@@ -111,17 +114,21 @@ Function Get-BloggerPost {
111114
112115 # Save the Post to a Markdown file
113116 " Markdown" {
114-
117+
115118 $title = $result.title
116119 $frontMatter = [ordered ]@ {
117120 postId = $result.id
118121 }
119- if ($result [' labels' ]) {
122+ if ($result.PSObject.Properties.Name -contains " labels" ) {
123+ Write-Verbose " Using post labels: $ ( $result.labels ) "
120124 $frontMatter [' tags' ] = $result.labels
121125 } else {
126+ Write-Verbose " No labels found in post, using empty tags."
122127 $frontMatter [' tags' ] = @ ()
123128 }
129+ Write-Verbose " Saving frontmatter: $ ( $frontMatter | ConvertTo-Json - Depth 10 ) "
124130 $file = " $title .md"
131+
125132 $filePath = Join-Path - Path $OutDirectory - ChildPath $file
126133 ConvertTo-MarkdownFromHtml - Content $result.content - OutFile $filePath > $null
127134 Set-MarkdownFrontMatter - File $filePath -Replace $frontMatter
@@ -140,7 +147,7 @@ Function Get-BloggerPost {
140147 return $result
141148 }
142149 catch {
143- throw " Failed to save post content to file ' $filePath ' : $ ( $_.Exception.Message ) "
150+ throw " Failed to save post content: $ ( $_.Exception.Message ) "
144151 }
145152 }
146153 catch {
0 commit comments