File tree Expand file tree Collapse file tree 3 files changed +30
-20
lines changed
Expand file tree Collapse file tree 3 files changed +30
-20
lines changed Original file line number Diff line number Diff line change 1717 "private" : true ,
1818 "scripts" : {
1919 "astro" : " astro" ,
20- "build" : " astro check && astro build && scripts/patch-sitemap .sh" ,
20+ "build" : " astro check && astro build && scripts/patch.sh" ,
2121 "dev" : " astro dev" ,
2222 "preview" : " astro preview" ,
2323 "start" : " astro dev"
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ function patch_sitemap() {
4+ # Remove the sitemap index file (we only have one sitemap)
5+ rm dist/sitemap-index.xml
6+ mv dist/sitemap-0.xml dist/sitemap.xml
7+
8+ # Add lastmod dates to sitemap entries
9+ # Use current date as lastmod for all entries since we don't track per-page dates
10+ CURRENT_DATE=$( date -u +" %Y-%m-%d" )
11+
12+ # Use sed to add <lastmod> after each <loc> tag
13+ # This works on both macOS and Linux
14+ if [[ " $OSTYPE " == " darwin" * ]]; then
15+ # macOS
16+ sed -i ' ' " s|</loc>|</loc><lastmod>${CURRENT_DATE} </lastmod>|g" dist/sitemap.xml
17+ else
18+ # Linux
19+ sed -i " s|</loc>|</loc><lastmod>${CURRENT_DATE} </lastmod>|g" dist/sitemap.xml
20+ fi
21+ }
22+
23+ function patch_link_rel_icon() {
24+ # find rel="shortcut icon" and replace with rel="icon" in every html file in dist
25+ find dist -name " *.html" -exec sed -i " " " s|rel=\" shortcut icon\" |rel=\" icon\" |g" {} \;
26+ }
27+
28+ patch_sitemap
29+ patch_link_rel_icon
You can’t perform that action at this time.
0 commit comments