Skip to content

Commit 50319e1

Browse files
committed
Initial commit for NT;RE site
* Just a test for now and see action works
0 parents  commit 50319e1

File tree

7 files changed

+166
-0
lines changed

7 files changed

+166
-0
lines changed

.github/workflows/generate.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Deploy to github page
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
7+
# Allows you to run this workflow manually from the Actions tab
8+
workflow_dispatch:
9+
10+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
17+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
18+
concurrency:
19+
group: "pages"
20+
cancel-in-progress: false
21+
22+
jobs:
23+
# Single deploy job since we're just deploying
24+
deploy:
25+
environment:
26+
name: github-pages
27+
url: ${{ steps.deployment.outputs.page_url }}
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: awalsh128/cache-apt-pkgs-action@latest
31+
with:
32+
packages: lowdown
33+
version: 1.0
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
- name: Generate
37+
run: make
38+
- name: Upload artifact
39+
uses: actions/upload-pages-artifact@v3
40+
with:
41+
path: '_out'
42+
- name: Deploy to GitHub Pages
43+
id: deployment
44+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/_out

Makefile

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
SITE_HTTPS_URL := https://neotokyorebuild.github.io/
2+
SITE_TITLE := Neotokyo; Rebuild
3+
4+
SRC_DIR := src
5+
DST_DIR := _out
6+
SRCS := $(shell find $(SRC_DIR) -name '*.md')
7+
SRCS_CPY := $(SRC_DIR)/style.css
8+
9+
BLOG_LIST_FILE := $(DST_DIR)/blog_list
10+
DSTS_HTML := $(SRCS:$(SRC_DIR)/%.md=$(DST_DIR)/%.html)
11+
DSTS_HTML_CPY := $(SRCS_CPY:$(SRC_DIR)/%=$(DST_DIR)/%)
12+
13+
all: html
14+
15+
clean:
16+
rm -fr $(DST_DIR)
17+
18+
serve:
19+
python3 -m http.server -d $(DST_DIR)
20+
21+
$(DST_DIR)/%.html: $(SRC_DIR)/%.md $(SRC_DIR)/_header.html $(SRC_DIR)/_footer.html
22+
@echo html: $@
23+
@mkdir -p $(dir $@)
24+
@SSG_TITLE=$$(lowdown -X title $<); \
25+
m4 -DSSG_TITLE="$$SSG_TITLE" $(SRC_DIR)/_header.html > $@.header.html.tmp
26+
@lowdown -Thtml -o $@.tmp $<
27+
@cat $@.header.html.tmp $@.tmp $(SRC_DIR)/_footer.html > $@
28+
@rm $@.tmp $@.header.html.tmp
29+
@case $< in $(SRC_DIR)/blog/*) \
30+
entry_date=$$(dir $< | cut -d'/' -f3); \
31+
echo "$$entry_date $$(lowdown -X title $<)" >> $(BLOG_LIST_FILE);; \
32+
esac
33+
34+
$(DST_DIR)/%: $(SRC_DIR)/%
35+
@echo "html (copy):" $@
36+
@mkdir -p $(dir $@)
37+
@cp $< $@
38+
39+
$(DST_DIR)/blog/index.html: $(SRC_DIR)/blog/*/*.md $(SRC_DIR)/_header.html $(SRC_DIR)/_footer.html
40+
@echo "html (blog):" $@
41+
@echo "<h1>Blog</h1><ul>" > $@.mid
42+
@mv $(BLOG_LIST_FILE) $(BLOG_LIST_FILE).tmp
43+
@cat $(BLOG_LIST_FILE).tmp | sort -ur > $(BLOG_LIST_FILE)
44+
@rm $(BLOG_LIST_FILE).tmp
45+
@cat $(BLOG_LIST_FILE) | while read line; do \
46+
entry_date=$$(echo "$$line" | cut -f1); \
47+
title=$$(echo "$$line" | cut -f2); \
48+
echo "<li><a href=\"$$entry_date\">$$entry_date - $$title</a></li>"; \
49+
done >> $@.mid
50+
@echo "</ul>" >> $@.mid
51+
@m4 -DSSG_TITLE="Blog" $(SRC_DIR)/_header.html > $@.header
52+
@cat $@.header $@.mid $(SRC_DIR)/_footer.html > $@
53+
@rm $@.header $@.mid
54+
55+
$(DST_DIR)/blog/atom.xml: $(SRC_DIR)/blog/*/*.md
56+
@echo "html (atom):" $@
57+
@echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>" > $@
58+
@echo "<feed xmlns=\"http://www.w3.org/2005/Atom\">" >> $@
59+
@echo "<title type=\"text\">$(SITE_TITLE)</title>" >> $@
60+
@echo "<updated>$$(head -n1 "$(BLOG_LIST_FILE)" | cut -f1)T00:00:00Z</updated>" >> $@
61+
@echo "<id>$(SITE_HTTPS_URL)blog/</id>" >> $@
62+
@echo "<author><name>$(SITE_TITLE)</name></author>" >> $@
63+
@echo "<link rel=\"alternate\" type=\"text/html\" href=\"$(SITE_HTTPS_URL)blog/\"/>" >> $@
64+
@echo "<link rel=\"self\" type=\"application/atom+xml\" href=\"$(SITE_HTTPS_URL)blog/atom.xml\"/>" >> $@
65+
@cat $(BLOG_LIST_FILE) | while read line; do \
66+
entry_date=$$(echo "$$line" | cut -f1); \
67+
title=$$(echo "$$line" | cut -f2); \
68+
entry_url=$$(echo "$(SITE_HTTPS_URL)blog/$$entry_date/"); \
69+
echo "<entry>"; \
70+
echo "<title>$$title</title>"; \
71+
echo "<link rel=\"alternate\" type=\"text/html\" href=\"$$entry_url\"/>"; \
72+
echo "<updated>$${entry_date}T00:00:00Z</updated>"; \
73+
echo "<published>$${entry_date}T00:00:00Z</published>"; \
74+
echo "<summary>$$(lowdown -X summary $(SRC_DIR)/blog/$${entry_date}/index.md)</summary>"; \
75+
echo "<id>$$entry_url</id>"; \
76+
echo "</entry>"; \
77+
done >> $@
78+
@echo "</feed>" >> $@
79+
80+
html: $(DSTS_HTML) $(DSTS_HTML_CPY) #$(DST_DIR)/blog/index.html $(DST_DIR)/blog/atom.xml
81+
82+
.PHONY: all clean html
83+

src/_footer.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
</body>
2+
</html>
3+

src/_header.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<title>SSG_TITLE | Neotokyo; Rebuild</title>
7+
<link rel="alternate" href="/blog/atom.xml" type="application/atom+xml" title="Neotokyo; Rebuild blog atom feed">
8+
<link rel="stylesheet" href="/style.css">
9+
<link rel="icon" href="/favicon.ico">
10+
</head>
11+
<body>
12+
<p><b>Neotokyo; Rebuild</b> - <a href="/">home</a> | <a href="/blog">blog</a> | <a href="/blog/atom.xml">atom</a></p>
13+
<hr>
14+

src/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
title: Home
2+
3+
# Neotokyo; Rebuild
4+

src/style.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
body {
2+
font-family: monospace;
3+
max-width: 70em;
4+
margin: 1em auto;
5+
padding: 0 10px;
6+
background-color: black;
7+
color: #EEEEEE;
8+
}
9+
10+
a {
11+
color: #9999EE;
12+
}
13+
14+
a:hover, a:active {
15+
color: #CCCCFF;
16+
}
17+

0 commit comments

Comments
 (0)