File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 4040 mv _posts/r/md/ggplot2 _posts/ggplot2/md
4141 mv _posts/fsharp/html/csharp _posts/csharp/html
4242
43+ - name : Fix case-sensitive redirect issues
44+ run : python fix-case-redirects.py _posts/julia/html
45+
4346 - name : Build site
4447 run : |
4548 python front-matter-ci.py _posts
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+ import frontmatter
3+ from pathlib import Path
4+ import sys
5+
6+ for path in sys .argv [1 :]:
7+ for f in Path (path ).glob ("**/*.html" ):
8+ try :
9+ post = frontmatter .load (f )
10+ except :
11+ continue
12+
13+ permalink = post .get ('permalink' , '' ).lower ()
14+ redirects = post .get ('redirect_from' , [])
15+ if isinstance (redirects , str ):
16+ redirects = [redirects ]
17+
18+ fixed = [r for r in redirects if r .lower () != permalink ]
19+
20+ if len (fixed ) < len (redirects ):
21+ removed = [r for r in redirects if r .lower () == permalink ]
22+ print (f"{ f } : removed { removed } " )
23+ if fixed :
24+ post ['redirect_from' ] = fixed
25+ else :
26+ del post ['redirect_from' ]
27+ with open (f , 'w' ) as out :
28+ out .write (frontmatter .dumps (post ))
You can’t perform that action at this time.
0 commit comments