Skip to content

Commit 942db02

Browse files
committed
initial commit
0 parents  commit 942db02

10 files changed

+180
-0
lines changed

.envrc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
if command -v lorri &>/dev/null; then
2+
echo "direnv: using lorri"
3+
eval "$(lorri direnv)"
4+
else
5+
# fall back to using direnv's builtin nix support
6+
# to prevent bootstrapping problems.
7+
use nix
8+
fi

.gitignore

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/default.md
2+
/org/pdfs/
3+
/node_modules/
4+
/resources/
5+
/org/biblio/auto/
6+
/org/org-roam.db
7+
/org/org-fc.tsv
8+
/public/
9+
/org/work/
10+
org/private/
11+
/org/lit/.auctex-auto/
12+
/.ninja_log
13+
/build.ninja
14+
/org/daily/
15+
/.emacs.d
16+
/content/posts

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "themes/cortex"]
2+
path = themes/cortex
3+
url = https://github.com/contrun/cortex/

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Build instructions
2+
3+
```bash
4+
emacs --batch -l publish.el --eval "(publish-all)"
5+
git submodule update --recursive --init
6+
hugo
7+
```

build.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#! /usr/bin/env nix-shell
2+
#! nix-shell -i python3 -p python3 ninja
3+
4+
import glob
5+
from pathlib import Path
6+
7+
files = glob.glob("org/*.org")
8+
9+
with open('build.ninja', 'w') as ninja_file:
10+
ninja_file.write("""
11+
rule org2md
12+
command = emacs --batch -l publish.el --eval \"(publish \\"$in\\")"
13+
description = org2md $in
14+
""")
15+
16+
for f in files:
17+
path = Path(f)
18+
output_file = f"content/posts/{path.with_suffix('.md').name}"
19+
ninja_file.write(f"""
20+
build {output_file}: org2md {path}
21+
""")
22+
23+
import subprocess
24+
subprocess.call(["ninja"])

config.toml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
baseURL = "https://contrun.github.io/km/"
2+
languageCode = "en-us"
3+
title = "untitiled"
4+
theme = "cortex"
5+
canonifyURLs = true
6+
relativeUrls = true
7+
8+
[params]
9+
10+
11+
[markup]
12+
[markup.goldmark]
13+
[markup.goldmark.extensions]
14+
definitionList = true
15+
footnote = true
16+
linkify = true
17+
strikethrough = true
18+
table = true
19+
taskList = true
20+
typographer = true
21+
[markup.goldmark.parser]
22+
attribute = true
23+
autoHeadingID = true
24+
[markup.goldmark.renderer]
25+
hardWraps = false
26+
unsafe = true
27+
xHTML = false
28+
29+
[markup.highlight]
30+
codeFences = true
31+
guessSyntax = false
32+
hl_Lines = ""
33+
lineNoStart = 1
34+
lineNos = false
35+
lineNumbersInTable = true
36+
noClasses = true
37+
style = "friendly"
38+
tabWidth = 4
39+
40+
[permalinks]
41+
posts = "/:title/"

content/_index.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
+++
2+
title = "Index"
3+
lastmod = 2020-05-29T21:44:03+08:00
4+
type = "index"
5+
draft = false
6+
+++
7+
8+
# Table of Contents

publish.el

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
(setq package-enable-at-startup nil)
2+
3+
(defconst my/current-dir
4+
(if load-file-name
5+
(file-name-directory load-file-name)
6+
(expand-file-name ".")))
7+
8+
(defconst my/emacs-dir
9+
;;; Customized `user-emacs-directory', used for several separate configurations.
10+
(expand-file-name ".emacs.d" my/current-dir))
11+
12+
(defconst my/org-dir
13+
;;; Org files directory
14+
(expand-file-name "org" my/current-dir))
15+
16+
(setq straight-base-dir (expand-file-name "straight" my/emacs-dir))
17+
(unless (file-exists-p straight-base-dir)
18+
(make-directory straight-base-dir t))
19+
(defvar bootstrap-version)
20+
(let ((bootstrap-file
21+
(expand-file-name "straight/repos/straight.el/bootstrap.el" straight-base-dir))
22+
(bootstrap-version 5))
23+
(unless (file-exists-p bootstrap-file)
24+
(with-current-buffer
25+
(url-retrieve-synchronously
26+
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
27+
'silent 'inhibit-cookies)
28+
(goto-char (point-max))
29+
(eval-print-last-sexp)))
30+
(load bootstrap-file nil 'nomessage))
31+
32+
(straight-use-package 'use-package)
33+
34+
(setq org-id-locations-file (expand-file-name ".org-id-locations" my/emacs-dir))
35+
(use-package org-roam
36+
:straight t
37+
:init
38+
(setq org-roam-directory my/org-dir)
39+
(setq org-roam-db-location (expand-file-name "org-roam.db" my/org-dir))
40+
(org-roam-mode)
41+
(unless (file-exists-p org-id-locations-file)
42+
(let ((org-id-files (org-roam--list-files org-roam-directory))
43+
org-agenda-files)
44+
(org-id-update-id-locations)))
45+
)
46+
47+
(use-package ox-hugo
48+
:straight (ox-hugo :type git :host github :repo "kaushalmodi/ox-hugo"
49+
:fork (:host github
50+
:repo "jethrokuan/ox-hugo")))
51+
52+
(defun publish (file)
53+
(with-current-buffer (find-file-noselect file)
54+
(setq org-hugo-base-dir my/current-dir)
55+
(org-hugo-export-wim-to-md)))
56+
57+
(defun publish-all ()
58+
(let* ((all-org-files (file-expand-wildcards (expand-file-name "*.org" my/org-dir))))
59+
(dolist (f all-org-files)
60+
(publish f))))

shell.nix

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
with import <nixpkgs> {};
2+
3+
pkgs.mkShell {
4+
buildInputs = with pkgs; [
5+
nodejs
6+
nodePackages.prettier
7+
hugo
8+
];
9+
shellHook = ''
10+
alias start="hugo server"
11+
'';
12+
}

themes/cortex

Submodule cortex added at f33b748

0 commit comments

Comments
 (0)