diff --git a/.gitignore b/.gitignore index 439dc65..6d2b586 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /articles/ +/js/config.js diff --git a/README.md b/README.md index c636baa..5a8261b 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,8 @@ from the library — not something an embedding page needs to bring along. │ ├── toc.css # Auto-generated table of contents │ └── author-profile.css # Author profile card (avatar, bio, social links) ├── js/ -│ ├── config.js # BASE_URL, MARKED_URL, ARTICLES_URL (all via import.meta.url) +│ ├── config-default.js # Shipped defaults for BASE_URL, MARKED_URL, ARTICLES_URL +│ ├── config.js # Your local overrides — gitignored; see "Local configuration" below │ ├── frontmatter.js # parseFrontmatter() — pure YAML-front parser │ ├── templates.js # loadTemplates(), templates cache │ ├── discovery.js # discoverArticles(), fetchJson(), article cache @@ -86,6 +87,31 @@ from the library — not something an embedding page needs to bring along. └── slug~DDMMYYYY~tag1+tag2.md # One file per article — see "Adding an article" ``` +## Local configuration + +**Before first use, create your own `js/config.js`** — it doesn't ship with the repo (it's +gitignored) and nothing works without it: + +```bash +cp js/config-default.js js/config.js +``` + +`js/config-default.js` holds the shipped defaults (`BASE_URL`, `MARKED_URL`, `ARTICLES_URL`) and +is tracked in git; every other module imports from `js/config.js` instead, which by default just +re-exports those defaults unchanged. The split exists for using cmjs as a git submodule (or +otherwise pulling in a newer version some other way): since `config.js` is gitignored, updating +cmjs never overwrites it, so any local overrides you've made survive the update. Only +`config-default.js` gets updated. + +To override a setting, re-export the rest from `config-default.js` and define your own instead — +e.g. to move where articles live (see "Pointing articles/ somewhere else" below for the matching +nginx-side change this needs): + +```js +export { BASE_URL, MARKED_URL } from './config-default.js'; +export const ARTICLES_URL = new URL('/blog-content/articles/', location.origin).href; +``` + ## Adding an article An article is a single Markdown file placed directly in its author's directory. Its *file name* @@ -254,6 +280,9 @@ translate it by editing that page directly (`demo/index.html` for this repo's ow ## Embedding in an existing page +Make sure you've done the one-time setup in "Local configuration" above (`cp js/config-default.js +js/config.js`) wherever you place these files — nothing loads without it. + To add cmjs to any HTML page, three things are needed: the CSS, the two mount-point `