Skip to content

Instantly share code, notes, and snippets.

.PHONY: help
help: ## Show this help
@egrep -h '\s##\s' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[34m%-15s\033[0m %s\n", $$1, $$2}'
$(DST_DIR)/robots.txt:
@echo "User-agent: *" > $@
@echo "Allow: *" >> $@
@echo "Sitemap: $(BASE_URL)/sitemap.xml" >> $@
$(DST_DIR)/sitemap.xml: $(HTML_FILES)
@echo '<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' > $@
for f in $^; do \
@echo "<url><loc>$(BASE_URL)$${f#$(DST_DIR)}<loc></url>" >> $@
done
TEMPLATE = $(SRC_DIR)/template.html
$(DST_DIR)/%.html: $(SRC_DIR)/%.md $(TEMPLATE)
pandoc \
--from markdown_github+smart+yaml_metadata_block+auto_identifiers \
--to html \
--template $(TEMPLATE) \
-o $@ $<
.PHONY: clean
clean:
rm $(HTML_FILES)
rm -rf $(CSS_DIR)
.PHONY: html
html: $(HTML_FILES) ## Build all HTML files from Markdown
$(DST_DIR)/%.html: $(SRC_DIR)/%.md
pandoc --from markdown --to html --standalone $< -o $@
.PHONY: css
css: $(CSS_FILES) ## Build all CSS files from SCSS
$(CSS_DIR):
mkdir -p $@
$(CSS_DIR)/%.css: $(SCSS_DIR)/%.scss $(SCSS_INCLUDES_DIR)/_*.scss | $(CSS_DIR)
sass --load-path=$(SCSS_INCLUDES_DIR) --style=compressed --scss $< $@
$(CSS_DIR)/%.css: $(SCSS_DIR)/%.scss $(SCSS_INCLUDES_DIR)/_*.scss
sass --load-path=$(SCSS_INCLUDES_DIR) --style=compressed --scss $< $@
all: html css
html:
@echo "Building some HTML..."
css:
@echo "Building some CSS..."
@mig-hub
mig-hub / Static_Website.mk
Last active September 27, 2024 22:49
Makefile for generating a static website
SRC_DIR = src
DST_DIR = build
CSS_DIR = $(DST_DIR)/css
SCSS_DIR = $(SRC_DIR)/scss
SCSS_INCLUDES_DIR = $(SCSS_DIR)/includes
SCSS_FILES = $(wildcard $(SCSS_DIR)/*.scss)
CSS_FILES=$(patsubst $(SCSS_DIR)/%.scss, $(CSS_DIR)/%.css, $(SCSS_FILES))
@mig-hub
mig-hub / usa.rb
Created February 26, 2019 12:48
Ruby module with United States of America (Name and ISO code)
module USA
extend self
def full_state_list
[
self.state_list,
self.outlying_territories,
self.armed_forces
].reduce(&:concat)