Personal website

sayings: generalize functions, change md format

* instead of packing header in the 1st line, delimit it with `%---`to allow multi-line
* move content retrieval to own function
* component function now takes .md path instead of the parsed header (does it by itself)

helpimnotdrowning.net d3cefaa9 48dac642

verified
+27 -14
+9 -2
functions.ps1
··· 149 149 } 150 150 } 151 151 152 - function _parse_saying_header { 152 + function _parse_post_header { 153 153 param ([IO.FileInfo] $Path) 154 - $Data = Get-Content $Path | Select-Object -First 1 | ConvertFrom-Json -AsHashtable 154 + $Data = Get-Content $Path -Raw | % { ($_ -split '%---')[0] } | ConvertFrom-Json -AsHashtable 155 155 $Data.Path = (Join-Path /sayings $Path.BaseName) 156 156 157 157 return $Data 158 158 } 159 + 160 + function _get_post_content { 161 + param ([IO.FileInfo] $Path) 162 + $Content = Get-Content $Path -Raw | % { ($_ -split '%---')[1] } 163 + 164 + return ConvertFrom-Markdown -InputObject $Content | % Html 165 + }
+6 -1
sayings/making-of-mizumiya.md
··· 1 - { "Title": "Making of Mizumiya", "Description": "Mizumiya's creation story as an HTML DSL for PowerShell, its core functionality, and notes on a few quirks.", "Created": "2025-10-10" } 1 + { 2 + "Title": "Making of Mizumiya", 3 + "Description": "Mizumiya's creation story as an HTML DSL for PowerShell, its core functionality, and notes on a few quirks.", 4 + "Created": "2025-10-10" 5 + } 6 + %--- 2 7 # Making of Mizumiya 3 8 4 9 <img src="img/mizumiya.jpg" align=middle class="mx-64" alt="Logo/banner of Mizumiya" />
+6 -1
sayings/powershell-test.md
··· 1 - { "Title": "PowerShell syntax test file", "Description": "file test for custom prism.js PowerShell syntax highlighter", "Created": "2025-09-22" } 1 + { 2 + "Title": "PowerShell syntax test file", 3 + "Description": "file test for custom prism.js PowerShell syntax highlighter", 4 + "Created": "2025-09-22" 5 + } 6 + %--- 2 7 ## POWERSHELL TEST FILE 3 8 4 9 ```pwsh
+5 -9
views/sayings.ps1
··· 16 16 #> 17 17 18 18 function _post_component { 19 - param ($PostData) 19 + param ($PostFile) 20 + 21 + $PostData = _parse_saying_header $PostFile 20 22 21 23 div -Class 'post-component' { 22 24 h1 -Class 'post-title' { 23 25 a -Href $PostData.Path -InnerHTML $PostData.Title 24 26 } 25 27 p -Class 'flex gap-2' { 26 - span -Class 'text-current/50' {$PostData.Created} 28 + span -Class 'text-current/50' { $PostData.Created } 27 29 $PostData.Description 28 30 } 29 31 } ··· 38 40 link -Rel stylesheet -Type text/css -Href /style.css 39 41 _scripts 40 42 41 - script -Src /prism.js 42 - script @" 43 - Prism.plugins.autoloader.languages_path = '/prism/'; 44 - Prism.plugins.autoloader.use_minified = false; 45 - "@ 46 - 47 43 title Posts 48 44 meta -Name darkreader-lock 49 45 meta -Name description -Content "" ··· 58 54 59 55 for ($i=0; $i -lt $Posts.Count; $i++) { 60 56 try { 61 - _post_component (_parse_saying_header $Posts[$i]) 57 + _post_component $Posts[$i] 62 58 if ($i+1 -ne $Posts.Count) { 63 59 # add divider after all except last post 64 60 hr
+1 -1
views/sayings_post.ps1
··· 45 45 _header 46 46 47 47 div -Class "n-box xmin-h-[10em]! tx" -HxDisable { 48 - ConvertFrom-Markdown -InputObject (Get-Content $Path | Select-Object -skip 1 | Join-String -Sep "`n") | % Html 48 + _get_post_content $Path 49 49 } 50 50 } 51 51 }