Updated pre-commit to check for dead links, updated projects pages and new post
This commit is contained in:
parent
57c931c7cf
commit
a72883a13f
@ -54,3 +54,8 @@ OnePlus
|
||||
PostMarketOS
|
||||
Termux
|
||||
Uno
|
||||
gitea
|
||||
repo
|
||||
SDL
|
||||
otto
|
||||
drupals
|
||||
|
@ -1,9 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
GREEN='\033[0;32m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo "Running pre-commit checks..."
|
||||
|
||||
# Track overall success/failure
|
||||
OVERALL_RESULT=0
|
||||
|
||||
# Get list of staged markdown files
|
||||
STAGED_MD_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.md$' || true)
|
||||
|
||||
@ -16,10 +20,12 @@ echo "Checking markdown files..."
|
||||
|
||||
# Check markdown formatting with markdownlint-cli
|
||||
if command -v markdownlint &> /dev/null; then
|
||||
markdownlint $STAGED_MD_FILES || {
|
||||
echo "❌ Markdown linting failed. Fix issues or use 'git commit --no-verify' to skip."
|
||||
exit 1
|
||||
}
|
||||
if ! markdownlint $STAGED_MD_FILES; then
|
||||
echo "❌ Markdown linting failed."
|
||||
OVERALL_RESULT=1
|
||||
else
|
||||
echo -e "${GREEN}✅ Markdownlint passed!${NC}"
|
||||
fi
|
||||
else
|
||||
echo "⚠️ markdownlint not found, skipping markdown linting"
|
||||
fi
|
||||
@ -59,14 +65,31 @@ if command -v aspell &> /dev/null; then
|
||||
fi
|
||||
done
|
||||
if [ $MISSPELLED -eq 1 ]; then
|
||||
echo "Review spelling errors above. Add correct terms to .aspell.personal"
|
||||
echo "Use 'git commit --no-verify' to skip if needed."
|
||||
exit 1
|
||||
echo "❌ Spell check failed."
|
||||
OVERALL_RESULT=1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "⚠️ aspell not found, skipping spell check"
|
||||
fi
|
||||
|
||||
# Link validation
|
||||
if [ -x "./scripts/check-links.sh" ]; then
|
||||
echo "Running link validation..."
|
||||
if ! ./scripts/check-links.sh $STAGED_MD_FILES; then
|
||||
echo "❌ Link validation failed."
|
||||
OVERALL_RESULT=1
|
||||
fi
|
||||
else
|
||||
echo "⚠️ Link checker script not found or not executable, skipping link validation"
|
||||
fi
|
||||
|
||||
# Final result
|
||||
if [ $OVERALL_RESULT -eq 0 ]; then
|
||||
echo "✅ Pre-commit checks passed!"
|
||||
exit 0
|
||||
else
|
||||
echo ""
|
||||
echo "❌ Some pre-commit checks failed. Fix issues or use 'git commit --no-verify' to skip."
|
||||
exit 1
|
||||
fi
|
||||
|
@ -139,10 +139,7 @@
|
||||
// MD032/blanks-around-lists : Lists should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md032.md
|
||||
"MD032": true,
|
||||
// MD033/no-inline-html : Inline HTML : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md033.md
|
||||
"MD033": {
|
||||
// Allowed elements
|
||||
"allowed_elements": []
|
||||
},
|
||||
"MD033": false,
|
||||
// MD034/no-bare-urls : Bare URL used : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md034.md
|
||||
"MD034": true,
|
||||
// MD035/hr-style : Horizontal rule style : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md035.md
|
||||
@ -266,7 +263,7 @@
|
||||
// MD056/table-column-count : Table column count : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md056.md
|
||||
"MD056": true,
|
||||
// MD058/blanks-around-tables : Tables should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md058.md
|
||||
"MD058": true,
|
||||
"MD058": false,
|
||||
// MD059/descriptive-link-text : Link text should be descriptive : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md059.md
|
||||
"MD059": {
|
||||
// Prohibited link texts
|
||||
|
@ -1,10 +1,13 @@
|
||||
---
|
||||
title: "Projects"
|
||||
type: "page"
|
||||
lastmod: 2025-10-03T16:19:07-06:00
|
||||
---
|
||||
|
||||
Worked on frequently, updated on occassion.
|
||||
Worked on frequently, updated on occasion.
|
||||
|
||||
- ## [Game in Zig & SDL2 ⚡️](/projects/zig-sdl)
|
||||
- ## [Gaining 15 Pounds in 2025 :muscle:]()
|
||||
- ## [Drones :video_game: :helicopter:]()
|
||||
- # [Game in Zig & SDL2 ⚡️](/projects/zig-sdl)
|
||||
|
||||
<!-- - # [Gaining 15 Pounds in 2025 :muscle:]() -->
|
||||
|
||||
<!-- - # [Drones :video_game: :helicopter:]() -->
|
||||
|
@ -2,15 +2,17 @@
|
||||
title: "SDL Game in Zig"
|
||||
image: ""
|
||||
type: "page"
|
||||
date: "2025-01-10"
|
||||
lastmod: 2025-10-03T16:19:07-06:00
|
||||
---
|
||||
|
||||
# Zig Game Dev with SDL2
|
||||
|
||||
I'm making a game in Zig!
|
||||
I'm (was) making a game in Zig! Currently getting back into Zig.
|
||||
|
||||
Watch me stream it [here](https://twitch.tv/fosscat), or below!
|
||||
Watch me [stream on Twitch](https://twitch.tv/fosscat), or the embed below!
|
||||
|
||||
Repo for the project is [here](https://git.fosscat.com/n8r/zsdl)
|
||||
Repo for the project is [on my gitea](https://git.fosscat.com/n8r/zsdl)
|
||||
|
||||
<div id="twitch-embed"></div>
|
||||
|
||||
|
30
content/tils/hunter-gatherers-were-not-dumb.md
Normal file
30
content/tils/hunter-gatherers-were-not-dumb.md
Normal file
@ -0,0 +1,30 @@
|
||||
---
|
||||
date: 2025-10-05T20:08:25-06:00
|
||||
description: ""
|
||||
lastmod: 2025-10-05T20:08:25-06:00
|
||||
showTableOfContents: true
|
||||
type: "tils"
|
||||
title: "TIL: Hunter Gatherers Were Not Dumb"
|
||||
image: ""
|
||||
image_credit: ""
|
||||
image_alt: ""
|
||||
tags: ["history", ""]
|
||||
---
|
||||
|
||||
# Context
|
||||
|
||||
[As I mentioned](/tils/we-created-dogs-and-dogs-created-us), I'm really enjoying the
|
||||
[Sapiens](https://en.wikipedia.org/wiki/Sapiens:_A_Brief_History_of_Humankind) book. I was shocked to discover that
|
||||
hunter gatherer societies were comprised of extremely intelligent humans!
|
||||
|
||||
# Reflection
|
||||
|
||||
Because of my biases (and probably seeing many depictions of foolish looking cave men), I had
|
||||
assumed that what caused the human to "pull themselves out" of the wild animal stage and into
|
||||
the industrial age was them finally reaching a point of intelligence to do so. When, [the
|
||||
reality](https://www.bbc.com/future/article/20240517-the-human-brain-has-been-shrinking-and-no-one-quite-knows-why) is
|
||||
actually the opposite! The hunter gatherer people had to be so intimately familiar with their surroundings to survive.
|
||||
Weather patterns, migration patterns of many different animals, which foods were safe to eat, and how to prepare the
|
||||
foods for consumption. The variety of foods they gathered was also greater than the average person today eating cereal
|
||||
grains and one of four different meats. History is so fascinating. I find time and time again, my assumption of how or
|
||||
what something must have been is frequently proven completely wrong.
|
@ -15,7 +15,7 @@ tags: ["life", "dogs", "history"]
|
||||
|
||||
I started listening to [_Sapiens: A Brief History of Human
|
||||
kind_](https://en.wikipedia.org/wiki/Sapiens:_A_Brief_History_of_Humankind) and was struck at the significance of dogs
|
||||
in human history. I [realized](https://fosscat.com/tils/people-are-actually-right/) that dogs really are man's best
|
||||
in human history. I [realized](/tils/people-are-actually-right) that dogs really are man's best
|
||||
friend, and only animal that has evolved alongside us since the hunter gatherer period. Its incredible!
|
||||
|
||||
# Reflection
|
||||
|
25
layouts/partials/page.html
Normal file
25
layouts/partials/page.html
Normal file
@ -0,0 +1,25 @@
|
||||
<div class="post container">
|
||||
|
||||
<div class="post-header-section">
|
||||
<h1>{{ .Title | markdownify }}</h1>
|
||||
|
||||
{{ if ne .File.Path "projects.md" }}
|
||||
<p class="post-date">
|
||||
{{ if eq .Date .Lastmod }}
|
||||
{{ dateFormat (or .Site.Params.dateFormat "January 2, 2006") .Date}}
|
||||
{{ end }}
|
||||
{{ if lt .Date .Lastmod }}
|
||||
Updated {{ dateFormat (or .Site.Params.dateFormat "January 2, 2006") .Lastmod }}
|
||||
{{ end }}
|
||||
</p>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
<div class="post-content">
|
||||
{{ .Content }}
|
||||
</div>
|
||||
<!-- Back to top button -->
|
||||
{{ if .Site.Params.ShowBackToTopButton }}
|
||||
{{ partial "back-to-top.html" . }}
|
||||
{{ end }}
|
||||
</div>
|
150
scripts/check-links.sh
Executable file
150
scripts/check-links.sh
Executable file
@ -0,0 +1,150 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
# Color codes for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Function to check if a URL is reachable
|
||||
check_url() {
|
||||
local url="$1"
|
||||
local file="$2"
|
||||
local line_num="$3"
|
||||
|
||||
# Skip relative URLs and internal anchors
|
||||
if [[ "$url" =~ ^(#|/[^/]|\./) ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Skip mailto and other non-http protocols
|
||||
if [[ "$url" =~ ^(mailto:|ftp:|file:|javascript:) ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# For URLs without protocol, assume https
|
||||
if [[ ! "$url" =~ ^https?:// ]]; then
|
||||
url="https://$url"
|
||||
fi
|
||||
|
||||
# Use curl to check the URL with a reasonable timeout
|
||||
# Follow redirects, but limit to 5 redirects to prevent infinite loops
|
||||
local http_code
|
||||
http_code=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||
--max-time 10 \
|
||||
--max-redirs 5 \
|
||||
--retry 1 \
|
||||
--user-agent "Mozilla/5.0 (compatible; FossCat Link Checker)" \
|
||||
"$url" 2>/dev/null || echo "000")
|
||||
|
||||
# Consider 2xx and 3xx status codes as success
|
||||
if [[ "$http_code" =~ ^[23][0-9][0-9]$ ]]; then
|
||||
return 0
|
||||
else
|
||||
echo -e "${RED}❌ Dead link in $file:$line_num${NC}"
|
||||
echo -e " URL: $url"
|
||||
echo -e " Status: $http_code"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to extract and check links from a markdown file
|
||||
check_markdown_links() {
|
||||
local file="$1"
|
||||
local failed=0
|
||||
|
||||
echo "Checking links in $file..."
|
||||
|
||||
# Use a simpler approach that works with basic grep
|
||||
# Extract URLs from markdown links [text](url) and images 
|
||||
local urls=$(grep -o '\]([^)]*)' "$file" | sed 's/](\([^)]*\)).*/\1/' | grep -v '^$')
|
||||
|
||||
if [ -n "$urls" ]; then
|
||||
while IFS= read -r url; do
|
||||
if [ -n "$url" ]; then
|
||||
# Get line number where this URL appears
|
||||
local line_num=$(grep -n "$url" "$file" | head -1 | cut -d: -f1)
|
||||
if ! check_url "$url" "$file" "$line_num"; then
|
||||
failed=1
|
||||
fi
|
||||
fi
|
||||
done <<< "$urls"
|
||||
fi
|
||||
|
||||
# Also check for reference-style links [ref]: url
|
||||
local ref_urls=$(grep -o '^\[.*\]: *[^ ]*' "$file" | sed 's/^\[.*\]: *//' | grep -v '^$')
|
||||
|
||||
if [ -n "$ref_urls" ]; then
|
||||
while IFS= read -r url; do
|
||||
if [ -n "$url" ]; then
|
||||
local line_num=$(grep -n "$url" "$file" | head -1 | cut -d: -f1)
|
||||
if ! check_url "$url" "$file" "$line_num"; then
|
||||
failed=1
|
||||
fi
|
||||
fi
|
||||
done <<< "$ref_urls"
|
||||
fi
|
||||
|
||||
return $failed
|
||||
}
|
||||
|
||||
# Main function
|
||||
main() {
|
||||
local files_to_check=()
|
||||
local failed_files=0
|
||||
local total_files=0
|
||||
|
||||
# If arguments provided, check those files, otherwise check all markdown files
|
||||
if [ $# -gt 0 ]; then
|
||||
files_to_check=("$@")
|
||||
else
|
||||
while IFS= read -r -d '' file; do
|
||||
files_to_check+=("$file")
|
||||
done < <(find content -name "*.md" -type f -print0)
|
||||
fi
|
||||
|
||||
if [ ${#files_to_check[@]} -eq 0 ]; then
|
||||
echo -e "${YELLOW}No markdown files to check.${NC}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}🔗 Checking links in ${#files_to_check[@]} markdown file(s)...${NC}"
|
||||
echo
|
||||
|
||||
for file in "${files_to_check[@]}"; do
|
||||
if [ -f "$file" ]; then
|
||||
total_files=$((total_files + 1))
|
||||
if ! check_markdown_links "$file"; then
|
||||
failed_files=$((failed_files + 1))
|
||||
fi
|
||||
else
|
||||
echo -e "${YELLOW}⚠️ File not found: $file${NC}"
|
||||
fi
|
||||
done
|
||||
|
||||
echo
|
||||
if [ $failed_files -eq 0 ]; then
|
||||
echo -e "${GREEN}✅ All links are working! Checked $total_files file(s).${NC}"
|
||||
exit 0
|
||||
else
|
||||
echo -e "${RED}❌ Found broken links in $failed_files file(s) out of $total_files checked.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if curl is available
|
||||
if ! command -v curl &> /dev/null; then
|
||||
echo -e "${RED}❌ curl is required but not installed.${NC}"
|
||||
echo "Please install curl to use the link checker."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if basic grep and sed are available
|
||||
if ! command -v sed &> /dev/null; then
|
||||
echo -e "${RED}❌ sed is required but not installed.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
main "$@"
|
Loading…
Reference in New Issue
Block a user