@ozdao/scriptorium 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -108,6 +108,12 @@ for (const config of Object.values(configs.ssr)) {
108
108
  config.resolve.alias['@docs-theme'] = docs_dir;
109
109
 
110
110
  config.module.rules.push(
111
+ // Картинки из .md, которых нет в правиле ассетов martyrs (там png, jpg, webp,
112
+ // svg…): avif — обычный формат референсов и скриншотов.
113
+ {
114
+ test: /\.avif$/i,
115
+ type: 'asset/resource',
116
+ },
111
117
  // .md репозитория → Vue-компонент страницы + frontmatter и заголовки.
112
118
  {
113
119
  test: /\.md$/,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ozdao/scriptorium",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Documentation site generator on @ozdao/martyrs: markdown folders to an SSR site",
5
5
  "author": "OZ DAO <hello@ozdao.com>",
6
6
  "license": "GPL-3.0-or-later",
package/src/server.js CHANGED
@@ -9,7 +9,7 @@ import { fileURLToPath } from 'node:url';
9
9
  import express from 'express';
10
10
  import cookies from 'cookie-parser';
11
11
 
12
- import { docs_dir, loadSiteConfig } from './content/scan.js';
12
+ import { docs_dir, docs_root, loadSiteConfig } from './content/scan.js';
13
13
 
14
14
  // Статика пакета: favicon по умолчанию.
15
15
  const package_public = fileURLToPath(new URL('../public', import.meta.url));
@@ -39,6 +39,17 @@ const createServer = async () => {
39
39
  app.use(express.static(path.join(docs_dir, 'public')));
40
40
  app.use(express.static(package_public));
41
41
 
42
+ // Файлы репозитория по ссылкам из документов (референсы, логотипы, манифест):
43
+ // как VitePress отдаёт всё из папки исходников. Только медиа и данные, без
44
+ // скрытых папок и node_modules: исходники и конфиги наружу не отдаются.
45
+ app.use((req, res, next) => {
46
+ if (!/\.(?:png|jpe?g|gif|webp|avif|svg|mp4|webm|pdf|json)$/i.test(req.path)) return next();
47
+ if (/\/\.|\/node_modules\//.test(req.path)) return next();
48
+ // Папка самого сайта (конфиг, package.json, lockfile) — не документация.
49
+ if (req.path.startsWith(`/${path.relative(docs_root, docs_dir)}/`)) return next();
50
+ express.static(docs_root, { index: false, dotfiles: 'ignore' })(req, res, next);
51
+ });
52
+
42
53
  const server = http.createServer(app);
43
54
 
44
55
  // scriptorium start: SIGTERM (systemd, деплой) — штатный выход с кодом 0,