Skip to content

Commit d768622

Browse files
committed
chore(site): patch rel="icon"
1 parent 0ec59b6 commit d768622

File tree

3 files changed

+30
-20
lines changed

3 files changed

+30
-20
lines changed

site/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
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"

site/scripts/patch-sitemap.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

site/scripts/patch.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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

0 commit comments

Comments
 (0)