Use statdown and Renv

This commit is contained in:
2026-03-02 07:03:31 -08:00
parent d07972b407
commit 7983a30f4e
9 changed files with 5542 additions and 1 deletions

1
.Rprofile Normal file
View File

@@ -0,0 +1 @@
source("renv/activate.R")

0
.build_sentinel Normal file
View File

View File

@@ -74,13 +74,29 @@ serve: #> Start a Hugo server
help: #> Generate this help message
@gawk -f ${help_generator} $(MAKEFILE_LIST)
#-----------------------------------------------------------------------------#
#
# Rmd rendering via statdown
#
#-----------------------------------------------------------------------------#
# Discover all Rmd source files and derive their .md targets
RMD_SOURCES := $(wildcard content/posts/*/index.Rmd)
MD_TARGETS := $(RMD_SOURCES:.Rmd=.md)
# Pattern rule: render index.md from index.Rmd using statdown
# Re-render when renv.lock changes (package version update)
%/index.md: %/index.Rmd renv.lock
@echo "🔄 Rendering $<"
cd $* && Rscript -e 'renv::restore(prompt = FALSE); statdown::statdown_render("index.Rmd")'
#-----------------------------------------------------------------------------#
#
# Define file interface
#
#-----------------------------------------------------------------------------#
.build_sentinel: $(wildcard content/*/*)
.build_sentinel: $(MD_TARGETS) $(wildcard content/*/*)
@echo "\t 🏗️ Building site"
@# We call hugo with two options:
@# --cleanDestinationDir, to remove deleted files

4051
renv.lock Normal file

File diff suppressed because one or more lines are too long

7
renv/.gitignore vendored Normal file
View File

@@ -0,0 +1,7 @@
library/
local/
cellar/
lock/
python/
sandbox/
staging/

1419
renv/activate.R Normal file

File diff suppressed because it is too large Load Diff

20
renv/settings.json Normal file
View File

@@ -0,0 +1,20 @@
{
"bioconductor.version": null,
"external.libraries": [],
"ignored.packages": [],
"package.dependency.fields": [
"Imports",
"Depends",
"LinkingTo"
],
"ppm.enabled": null,
"ppm.ignored.urls": [],
"r.version": null,
"snapshot.dev": false,
"snapshot.type": "implicit",
"use.cache": true,
"vcs.ignore.cellar": true,
"vcs.ignore.library": true,
"vcs.ignore.local": true,
"vcs.manage.ignores": true
}

11
scripts/renv.lock Normal file
View File

@@ -0,0 +1,11 @@
pak::pkg_install(
c(
"knitr",
"tidyverse",
"reactable",
"htmltools",
"svglite"
)
)
renv::snapshot()
# vim: ft=r

16
scripts/watch-rmd.sh Normal file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
WATCH_DIR="content/posts"
echo "🚨 Watching ${WATCH_DIR} for changes..."
inotifywait -m -e close_write --format '%w%f' -r "$WATCH_DIR" | while read FILE; do
if [[ "$FILE" == *.Rmd ]]; then
POST_DIR=$(dirname "$FILE")
echo "🔄 Change detected in $FILE. Rendering..."
(cd "$POST_DIR" && Rscript -e 'renv::restore(prompt = FALSE); statdown::statdown_render("index.Rmd")')
echo "✅ Rendered ${FILE}"
fi
done