Files
folio/astro.config.mjs
mtpsandClaude Opus 5.5 a1dd42f710 Make folio site-agnostic and add the @mtps/waves avatar ring
- Drop `site: 'https://ig.mtps.pl'`. Nothing reads it (no canonical,
  og:url or sitemap), and the app shouldn't know which site it builds.
- Example content and README samples use a placeholder profile
  instead of mtps / mtps.pl.
- Ring the avatar with @mtps/waves, Instagram-style; without an avatar
  the initial sits on the waves. `.npmrc` points @mtps at the Gitea
  registry, and pnpm-workspace.yaml exempts the scope from
  minimumReleaseAge.
- package.json version 0.3.0, matching the next tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 13:10:46 +00:00

51 lines
1.8 KiB
JavaScript

// @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';
/**
* Astro copies the original photos into _astro/ even though pages only use
* the resized versions. The originals still carry their EXIF (GPS, camera,
* exact time), so delete every image no page references.
* @returns {import('astro').AstroIntegration}
*/
const dropUnusedOriginals = () => ({
name: 'drop-unused-originals',
hooks: {
'astro:build:done': ({ dir, pages, logger }) => {
const root = fileURLToPath(dir);
if (!existsSync(`${root}_astro`)) return;
const html = pages
.map(({ pathname }) => {
const page = pathname === '' ? 'index' : pathname.replace(/\/$/, '');
return readFileSync(`${root}${page}.html`, 'utf8');
})
.join('\n');
for (const file of readdirSync(`${root}_astro`)) {
if (/\.(jpe?g|png|webp|avif)$/i.test(file) && !html.includes(`/_astro/${file}`)) {
rmSync(`${root}_astro/${file}`);
logger.info(`removed unreferenced ${file}`);
}
}
},
},
});
// photos/ and profile/ to build from; the example content by default, a site
// repo's checkout when building a real site (FOLIO_CONTENT=../my-site)
const content = resolve(process.env.FOLIO_CONTENT ?? 'content');
export default defineConfig({
// p/<slug>.html instead of p/<slug>/index.html: static-server's nginx
// serves $uri.html, so /p/<slug> works without a trailing-slash redirect
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] } },
},
});