@ozdao/scriptorium 0.1.1 → 0.1.2
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.
- package/bin/scriptorium.js +6 -0
- package/package.json +1 -1
- package/src/server.js +10 -1
package/bin/scriptorium.js
CHANGED
|
@@ -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
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,15 @@ 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
|
+
express.static(docs_root, { index: false, dotfiles: 'ignore' })(req, res, next);
|
|
49
|
+
});
|
|
50
|
+
|
|
42
51
|
const server = http.createServer(app);
|
|
43
52
|
|
|
44
53
|
// scriptorium start: SIGTERM (systemd, деплой) — штатный выход с кодом 0,
|