Split the site out: build from a content directory

folio is now only the app. Photos and profile come from FOLIO_CONTENT
(content/ with the example photos by default), so a site repo such as
mtps/ig.mtps.pl keeps its own content and deployment and builds a pinned
folio tag against it. The release workflow and deploy config moved there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Mateusz PstruchaandClaude Opus 5.5 committed 2026-10-19 22:44:58 +02:00
1 parent e1c805aaf5
commit 4b96b506d4
26 files changed
+71 -159

No files matched your search

-88
View File
@@ -1,88 +0,0 @@
name: Release
# v1.2.3 -> build, release folio-1.2.3.tgz, deploy/static.yml (ig.mtps.pl)
on:
push:
tags: ['v*']
jobs:
release:
runs-on: rocky-10
outputs:
version: ${{ steps.meta.outputs.version }}
steps:
- name: Check out source
uses: actions/checkout@v4
- name: Derive version
id: meta
run: |
VERSION="${GITHUB_REF_NAME#v}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "$VERSION"
# Version comes from the packageManager field in package.json.
- name: Set up pnpm
uses: pnpm/action-setup@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Type check
run: pnpm check
- name: Build
run: pnpm build
# Originals carry EXIF (GPS, exact time); only resized copies may ship.
- name: Check published images for EXIF
run: pnpm check:metadata
- name: Create release archive
env:
VERSION: ${{ steps.meta.outputs.version }}
run: |
NAME="${{ gitea.event.repository.name }}-${VERSION}.tgz"
# Archive the *contents* of dist/ rather than dist/ itself, so it
# untars straight into a web root.
tar -czf "$NAME" -C dist .
sha256sum "$NAME" > "$NAME.sha256"
- name: Create release
uses: akkuman/gitea-release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
server_url: ${{ gitea.server_url }}
tag_name: ${{ gitea.ref_name }}
name: ${{ gitea.ref_name }}
files: |-
${{ gitea.event.repository.name }}-*.tgz
${{ gitea.event.repository.name }}-*.tgz.sha256
# static-server on kara downloads the release asset, so this runs after it
deploy:
needs: release
runs-on: rocky-10
# never run two deploys at once
concurrency:
group: deploy-${{ gitea.repository }}
cancel-in-progress: false
steps:
- name: Check out source
uses: actions/checkout@v4
- name: Deploy
uses: https://git.app.ygg/ygg/actions/deploy@v2
with:
type: static
dist-path: deploy/static.yml
extra-vars: |
static_release=${{ needs.release.outputs.version }}
ssh-key: ${{ secrets.DEPLOY_SSH_KEY }}
known-hosts: ${{ vars.DEPLOY_KNOWN_HOSTS }}
+46 -27
View File
@@ -1,46 +1,65 @@
# folio
A single-page photo profile at [ig.mtps.pl](https://ig.mtps.pl): name, bio and link on top, a justified grid of photos below, and a detail view per photo. Built with Astro, served by [static-server](https://git.app.ygg/ygg/static-server).
A single-page photo profile: name, bio and link on top, a justified grid of photos below (each photo keeps its own aspect ratio), and a detail view per photo. It's a static Astro site with no likes, comments or backend.
## Adding a photo
This repo is the app. Sites built with it live in their own repos and hold only their content and deployment, e.g. [mtps/ig.mtps.pl](https://git.app.ygg/mtps/ig.mtps.pl).
1. Export it to `photos/<slug>.jpg`, about 2048px on the long edge, cropped however you like (1:1, 2:3, 4:3, 16:9 all work). The slug becomes the URL: `/p/<slug>`. Starting it with the date (`2026-10-12-tatry`) keeps the folder sorted.
2. Optionally add `photos/<slug>.yml`:
## Content
```yaml
description: Sunrise over Morskie Oko # multiline works with |-
alt: Lake below a ridge at dawn # defaults to the description
taken: 2026-10-12T06:41 # defaults to EXIF DateTimeOriginal
location: # never taken from EXIF
name: Morskie Oko
lat: 49.2013 # with lon: links to OpenStreetMap
lon: 20.0712
```
folio builds from a content directory: `content/` (example photos) by default, or whatever `FOLIO_CONTENT` points at:
3. Commit, then release: `git tag v1.2.3 && git push --follow-tags`.
```
photos/
2026-10-12-tatry.jpg # ~2048px long edge, any crop (1:1, 2:3, 4:3, 16:9, …)
2026-10-12-tatry.yml # optional
profile/
profile.yml # name, bio, link
avatar.jpg # optional, otherwise the name's initial is shown
```
Photos are ordered newest first by `taken`. Undated photos go last.
The file name becomes the URL, `/p/<slug>`. Photos are ordered newest first; undated ones go last.
The published images are resized copies without EXIF. The build deletes the originals from `dist/`, and `pnpm check:metadata` fails the release if any image still has GPS data or a capture time.
`photos/<slug>.yml`, all fields optional:
## Profile
```yaml
description: Sunrise over Morskie Oko # multiline works with |-
alt: Lake below a ridge at dawn # defaults to the description
taken: 2026-10-12T06:41 # defaults to EXIF DateTimeOriginal
location: # never taken from EXIF
name: Morskie Oko
lat: 49.2013 # with lon: links to OpenStreetMap
lon: 20.0712
```
Edit `profile/profile.yml`. For a profile picture, put `profile/avatar.jpg` (or `.png`, `.webp`) next to it. Without one, the name's initial is shown.
`profile/profile.yml`:
```yaml
name: mtps
bio: Photos I'm happy with.
link:
url: https://www.mtps.pl
label: mtps.pl
```
Published images are resized copies without EXIF. The build deletes the originals from `dist/`, and `pnpm check:metadata` fails if any published image still has GPS data or a capture time. Run it before publishing a build.
## Development
```sh
pnpm install
pnpm dev # http://localhost:4321
pnpm check # types
pnpm build # dist/
pnpm check:metadata
pnpm dev # example content, http://localhost:4321
FOLIO_CONTENT=../ig.mtps.pl pnpm dev # a site's content
pnpm check # types
pnpm build && pnpm check:metadata # dist/
```
## Release and deploy
## Using it for a site
Pushing a `v*` tag runs `.gitea/workflows/release.yml`:
Pin a folio tag in the site repo and build it against the site's checkout, the way [ig.mtps.pl's release workflow](https://git.app.ygg/mtps/ig.mtps.pl/src/branch/main/.gitea/workflows/release.yml) does:
1. It builds the site and attaches `folio-<version>.tgz` to a Gitea release.
2. It calls `ygg/actions/deploy@v2` (SSH to kara, Ansible `deploy/static`) with `deploy/static.yml`.
3. That runs static-server for this release on port 11904, behind `ig.mtps.pl`.
1. Check out the site repo, and this repo at the pinned tag into `folio/`.
2. Run `pnpm install --frozen-lockfile` and `pnpm check` in `folio/`.
3. Build with `FOLIO_CONTENT=$GITHUB_WORKSPACE`, then run `pnpm check:metadata`.
4. Ship `folio/dist/`.
Tag this repo (`vX.Y.Z`) for changes a site should be able to pick up. Tags here only mark versions; nothing is released or deployed from this repo.
+10
View File
@@ -1,5 +1,6 @@
// @ts-check
import { existsSync, readdirSync, readFileSync, rmSync } from 'node:fs';
import { resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { defineConfig } from 'astro/config';
@@ -31,6 +32,10 @@ const dropUnusedOriginals = () => ({
},
});
// photos/ and profile/ to build from; the example content by default, a site
// repo's checkout when building a real site (FOLIO_CONTENT=../ig.mtps.pl)
const content = resolve(process.env.FOLIO_CONTENT ?? 'content');
export default defineConfig({
site: 'https://ig.mtps.pl',
// p/<slug>.html instead of p/<slug>/index.html: static-server's nginx
@@ -38,4 +43,9 @@ export default defineConfig({
build: { format: 'file' },
trailingSlash: 'never',
integrations: [dropUnusedOriginals()],
vite: {
define: { 'import.meta.env.FOLIO_CONTENT': JSON.stringify(content) },
resolve: { alias: { '@content': content } },
server: { fs: { allow: ['.', content] } },
},
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
-36
View File
@@ -1,36 +0,0 @@
---
# Static site: https://git.app.ygg/mtps/folio
#
# Deployed by .gitea/workflows/release.yml through ygg/actions/deploy
# (deploy/static playbook on kara).
#
# static_release is passed by the release workflow (-e static_release=1.2.3).
# For a manual run pass it the same way, there's deliberately no default here.
# Release assets are versioned (folio-<version>.tgz), and static-server only
# auto-detects *.tar.gz, so the asset is named explicitly.
static_stack_name: folio
domain: ig.mtps.pl
# /etc/nginx/certs/<cert>.conf on the nginx host
cert: mtps.pl
# static_service replaces the role default as a whole, so every key is required
static_service:
name: static
image: "{{ gitea_host }}/ygg/static-server:latest"
environment:
GITEA_REPOSITORY_URL: "https://{{ gitea_host }}/mtps/folio"
GITEA_RELEASE: "v{{ static_release }}"
GITEA_ASSET_NAME: "folio-{{ static_release }}.tgz"
SSL_CERT_FILE: /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
volumes:
- /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem:/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem:ro
ports:
- target: 8080
published: 11904
protocol: tcp
mode: ingress
replicas: 3
restart_policy:
condition: on-failure
View File
Whitespace-only changes.
+4
View File
@@ -0,0 +1,4 @@
interface ImportMetaEnv {
/** absolute path of the content directory, see astro.config.mjs */
readonly FOLIO_CONTENT: string;
}
+8 -5
View File
@@ -1,16 +1,16 @@
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { basename, join } from 'node:path';
import type { ImageMetadata } from 'astro';
import { z } from 'astro/zod';
import exifr from 'exifr';
import { parse } from 'yaml';
// photos/<slug>.jpg plus an optional photos/<slug>.yml sidecar
const images = import.meta.glob<ImageMetadata>('/photos/*.{jpg,jpeg,png,webp,avif}', {
// <content>/photos/<slug>.jpg plus an optional <slug>.yml sidecar
const images = import.meta.glob<ImageMetadata>('@content/photos/*.{jpg,jpeg,png,webp,avif}', {
eager: true,
import: 'default',
});
const sidecars = import.meta.glob<string>('/photos/*.{yml,yaml}', {
const sidecars = import.meta.glob<string>('@content/photos/*.{yml,yaml}', {
eager: true,
query: '?raw',
import: 'default',
@@ -64,7 +64,10 @@ async function load(path: string, image: ImageMetadata): Promise<Photo> {
if (taken && Number.isNaN(taken.getTime())) throw new Error(`${sidecarPath}: invalid taken`);
if (!taken) {
const exif = await exifr
.parse(readFileSync(join(process.cwd(), path)), ['DateTimeOriginal', 'CreateDate'])
.parse(readFileSync(join(import.meta.env.FOLIO_CONTENT, 'photos', basename(path))), [
'DateTimeOriginal',
'CreateDate',
])
.catch(() => undefined);
taken = exif?.DateTimeOriginal ?? exif?.CreateDate;
}
+3 -3
View File
@@ -1,9 +1,9 @@
import type { ImageMetadata } from 'astro';
import { z } from 'astro/zod';
import { parse } from 'yaml';
import raw from '../../profile/profile.yml?raw';
import raw from '@content/profile/profile.yml?raw';
const avatars = import.meta.glob<ImageMetadata>('/profile/avatar.{jpg,jpeg,png,webp,avif}', {
const avatars = import.meta.glob<ImageMetadata>('@content/profile/avatar.{jpg,jpeg,png,webp,avif}', {
eager: true,
import: 'default',
});
@@ -17,6 +17,6 @@ const Profile = z
.strict();
const result = Profile.safeParse(parse(raw));
if (!result.success) throw new Error(`profile/profile.yml: ${result.error.message}`);
if (!result.success) throw new Error(`profile.yml: ${result.error.message}`);
export const profile = { ...result.data, avatar: Object.values(avatars)[0] };