@riebeckite/honox 0.0.3 → 0.0.4
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/dist/index.js +972 -977
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -251,8 +251,8 @@ function isJavaScriptModule(filePath) {
|
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
// src/scaffold/index.ts
|
|
254
|
-
import
|
|
255
|
-
import
|
|
254
|
+
import fs6 from "node:fs/promises";
|
|
255
|
+
import path7 from "node:path";
|
|
256
256
|
|
|
257
257
|
// src/scaffold/localized-content.ts
|
|
258
258
|
var SCAFFOLD_LANGUAGES = [
|
|
@@ -1182,1080 +1182,1075 @@ function pluginsContent(language) {
|
|
|
1182
1182
|
return lines.join("\n");
|
|
1183
1183
|
}
|
|
1184
1184
|
|
|
1185
|
-
// src/
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
{ path: "app/server.ts", content: server() },
|
|
1196
|
-
{ path: "app/client.ts", content: client() },
|
|
1197
|
-
{ path: "app/config.ts", content: appConfig() },
|
|
1198
|
-
{ path: "app/content.ts", content: appContent() },
|
|
1199
|
-
{ path: "app/constants/paths.ts", content: paths() },
|
|
1200
|
-
{ path: "app/global.d.ts", content: globalDeclarations() },
|
|
1201
|
-
{ path: "app/style.css", content: style() },
|
|
1202
|
-
{ path: "app/components/site-header.tsx", content: siteHeader() },
|
|
1203
|
-
{ path: "app/components/article.tsx", content: article() },
|
|
1204
|
-
{ path: "app/routes/_renderer.tsx", content: renderer() },
|
|
1205
|
-
{ path: "app/routes/index.tsx", content: indexRoute() },
|
|
1206
|
-
{ path: "app/routes/[slug{.+}].tsx", content: slugRoute() }
|
|
1207
|
-
];
|
|
1185
|
+
// src/vite_plugin.ts
|
|
1186
|
+
import path6 from "node:path";
|
|
1187
|
+
|
|
1188
|
+
// src/asset_entries.ts
|
|
1189
|
+
import fs4 from "node:fs";
|
|
1190
|
+
import path4 from "node:path";
|
|
1191
|
+
import { uniqueStrings } from "@riebeckite/core";
|
|
1192
|
+
function writeRiebeckiteAssetEntries(config, paths2) {
|
|
1193
|
+
writeGeneratedFile(paths2.pluginStyles, createPluginStylesEntry(config));
|
|
1194
|
+
writeGeneratedFile(paths2.themeStyles, createThemeStylesEntry(config));
|
|
1208
1195
|
}
|
|
1209
|
-
function
|
|
1210
|
-
return
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
version: "0.0.0",
|
|
1215
|
-
type: "module",
|
|
1216
|
-
scripts: {
|
|
1217
|
-
dev: "riebeckite dev",
|
|
1218
|
-
build: "riebeckite build",
|
|
1219
|
-
check: "riebeckite check",
|
|
1220
|
-
doctor: "riebeckite doctor",
|
|
1221
|
-
inspect: "riebeckite inspect"
|
|
1222
|
-
},
|
|
1223
|
-
dependencies: {
|
|
1224
|
-
"@riebeckite/core": "^0.0.3",
|
|
1225
|
-
"@riebeckite/honox": "^0.0.3",
|
|
1226
|
-
"@riebeckite/plugin-color-mode": "^0.0.3",
|
|
1227
|
-
"@riebeckite/plugin-l10n": "^0.0.3",
|
|
1228
|
-
"@riebeckite/plugin-obsidian-markdown": "^0.0.3",
|
|
1229
|
-
"@riebeckite/theme-default": "^0.0.3",
|
|
1230
|
-
hono: "^4.12.25",
|
|
1231
|
-
honox: "0.1.56"
|
|
1232
|
-
},
|
|
1233
|
-
devDependencies: {
|
|
1234
|
-
"@hono/vite-build": "^1.11.1",
|
|
1235
|
-
"@riebeckite/cli": "^0.0.3",
|
|
1236
|
-
"@types/node": "^24.5.2",
|
|
1237
|
-
typescript: "^5.0.0",
|
|
1238
|
-
vite: "^8.0.9"
|
|
1239
|
-
}
|
|
1240
|
-
},
|
|
1241
|
-
null,
|
|
1242
|
-
2
|
|
1243
|
-
)}
|
|
1244
|
-
`;
|
|
1196
|
+
function createPluginStylesEntry(config) {
|
|
1197
|
+
return createStylesheetEntry(
|
|
1198
|
+
collectPluginStyleSpecifiers(config),
|
|
1199
|
+
"Plugin default styles, in resolved plugin order. Generated by @riebeckite/honox; do not edit. Import this before the theme stylesheet so a theme can override plugin defaults."
|
|
1200
|
+
);
|
|
1245
1201
|
}
|
|
1246
|
-
function
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
import { l10n } from "@riebeckite/plugin-l10n";
|
|
1252
|
-
import { obsidianMarkdown } from "@riebeckite/plugin-obsidian-markdown";
|
|
1253
|
-
import { defaultTheme } from "@riebeckite/theme-default";
|
|
1254
|
-
|
|
1255
|
-
export default defineConfig({
|
|
1256
|
-
site: {
|
|
1257
|
-
title: ${JSON.stringify(title)},
|
|
1258
|
-
description: ${JSON.stringify(description)},
|
|
1259
|
-
baseUrl: ${JSON.stringify(baseUrl)},
|
|
1260
|
-
locale: ${JSON.stringify(locale)},
|
|
1261
|
-
},
|
|
1262
|
-
content: {
|
|
1263
|
-
directory: "content",
|
|
1264
|
-
},
|
|
1265
|
-
theme: defaultTheme(),
|
|
1266
|
-
plugins: [
|
|
1267
|
-
obsidianMarkdown(),
|
|
1268
|
-
colorModePlugin(),
|
|
1269
|
-
l10n({
|
|
1270
|
-
defaultLang: ${JSON.stringify(defaultLanguageForLocale(locale))},
|
|
1271
|
-
languages: ${JSON.stringify(languages)},
|
|
1272
|
-
}),
|
|
1273
|
-
],
|
|
1274
|
-
});
|
|
1275
|
-
`;
|
|
1202
|
+
function createThemeStylesEntry(config) {
|
|
1203
|
+
return createStylesheetEntry(
|
|
1204
|
+
config.theme.styles.map((style2) => style2.moduleSpecifier),
|
|
1205
|
+
"Theme styles. Generated by @riebeckite/honox; do not edit. Import this after the plugin stylesheet so the theme wins the plugin/theme cascade."
|
|
1206
|
+
);
|
|
1276
1207
|
}
|
|
1277
|
-
function
|
|
1278
|
-
return
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
const appRoot = fileURLToPath(new URL(".", import.meta.url));
|
|
1290
|
-
|
|
1291
|
-
export default defineConfig({
|
|
1292
|
-
plugins: [
|
|
1293
|
-
honox({
|
|
1294
|
-
client: { input: ["/app/client.ts", "/app/style.css"] },
|
|
1295
|
-
}),
|
|
1296
|
-
riebeckite({ appRoot }),
|
|
1297
|
-
build(),
|
|
1298
|
-
riebeckiteSsg({
|
|
1299
|
-
entry: path.join(appRoot, "app/server.ts"),
|
|
1300
|
-
extensionMap: riebeckiteSsgExtensionMap(),
|
|
1301
|
-
}),
|
|
1302
|
-
],
|
|
1303
|
-
environments: {
|
|
1304
|
-
ssr: {
|
|
1305
|
-
resolve: {
|
|
1306
|
-
external: [
|
|
1307
|
-
"extend",
|
|
1308
|
-
"debug",
|
|
1309
|
-
"node:fs/promises",
|
|
1310
|
-
"node:path",
|
|
1311
|
-
"parse-numeric-range",
|
|
1312
|
-
"slugify",
|
|
1313
|
-
"vfile-matter",
|
|
1314
|
-
],
|
|
1315
|
-
},
|
|
1316
|
-
},
|
|
1317
|
-
},
|
|
1318
|
-
});
|
|
1208
|
+
function collectPluginStyleSpecifiers(config) {
|
|
1209
|
+
return config.plugins.flatMap(
|
|
1210
|
+
(plugin) => (plugin.assets ?? []).filter((asset) => asset.kind === "style").map((asset) => asset.moduleSpecifier)
|
|
1211
|
+
);
|
|
1212
|
+
}
|
|
1213
|
+
function createStylesheetEntry(moduleSpecifiers, banner) {
|
|
1214
|
+
const imports = uniqueStrings(moduleSpecifiers).map((specifier) => `@import ${JSON.stringify(specifier)};`).join("\n");
|
|
1215
|
+
if (!banner) return imports;
|
|
1216
|
+
const header = `/* ${banner.replace(/\*\//g, "* /")} */`;
|
|
1217
|
+
return imports ? `${header}
|
|
1218
|
+
${imports}
|
|
1219
|
+
` : `${header}
|
|
1319
1220
|
`;
|
|
1320
1221
|
}
|
|
1321
|
-
function
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
},
|
|
1339
|
-
include: [
|
|
1340
|
-
"app/**/*.ts",
|
|
1341
|
-
"app/**/*.tsx",
|
|
1342
|
-
"riebeckite.config.ts",
|
|
1343
|
-
"vite.config.ts"
|
|
1344
|
-
]
|
|
1222
|
+
function writeGeneratedFile(filePath, contents) {
|
|
1223
|
+
fs4.mkdirSync(path4.dirname(filePath), { recursive: true });
|
|
1224
|
+
fs4.writeFileSync(filePath, contents);
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
// src/client_module.ts
|
|
1228
|
+
import {
|
|
1229
|
+
serializePublicClientConfig
|
|
1230
|
+
} from "@riebeckite/core";
|
|
1231
|
+
var clientModuleId = "virtual:riebeckite/client";
|
|
1232
|
+
var resolvedClientModuleId = `\0${clientModuleId}`;
|
|
1233
|
+
function riebeckiteClientModule(getConfig) {
|
|
1234
|
+
return {
|
|
1235
|
+
name: "riebeckite-client-module",
|
|
1236
|
+
resolveId(id) {
|
|
1237
|
+
if (id === clientModuleId) return resolvedClientModuleId;
|
|
1238
|
+
return null;
|
|
1345
1239
|
},
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1240
|
+
load(id) {
|
|
1241
|
+
if (id !== resolvedClientModuleId) return null;
|
|
1242
|
+
return createClientModule(getConfig());
|
|
1243
|
+
}
|
|
1244
|
+
};
|
|
1350
1245
|
}
|
|
1351
|
-
function
|
|
1352
|
-
|
|
1246
|
+
function createClientModule(config) {
|
|
1247
|
+
const imports = [];
|
|
1248
|
+
const initializers = [];
|
|
1249
|
+
for (const [index, entry] of config.plugins.flatMap((plugin) => plugin.clientEntries ?? []).entries()) {
|
|
1250
|
+
const localName = `pluginClientInitializer${index}`;
|
|
1251
|
+
const importTarget = entry.exportName ? `{ ${entry.exportName} as ${localName} }` : localName;
|
|
1252
|
+
imports.push(
|
|
1253
|
+
`import ${importTarget} from ${JSON.stringify(entry.moduleSpecifier)};`
|
|
1254
|
+
);
|
|
1255
|
+
const publicConfig = entry.publicConfig;
|
|
1256
|
+
initializers.push(
|
|
1257
|
+
publicConfig === void 0 ? `${localName}()` : `${localName}(${serializePublicClientConfig(publicConfig)})`
|
|
1258
|
+
);
|
|
1259
|
+
}
|
|
1260
|
+
return `${imports.join("\n")}
|
|
1261
|
+
|
|
1262
|
+
export function initRiebeckiteClient() {
|
|
1263
|
+
${initializers.map((initializer) => ` ${initializer};`).join("\n")}
|
|
1353
1264
|
}
|
|
1354
|
-
|
|
1355
|
-
return defaultLanguageForLocale(variables.locale) === "ja" ? jaReadme(variables) : enReadme(variables);
|
|
1265
|
+
`;
|
|
1356
1266
|
}
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
"
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1267
|
+
|
|
1268
|
+
// src/ssg_plugin.ts
|
|
1269
|
+
import { defaultExtensionMap, toSSG } from "hono/ssg";
|
|
1270
|
+
import { relative } from "node:path";
|
|
1271
|
+
import { createServer } from "vite";
|
|
1272
|
+
var defaultEntry = "./src/index.tsx";
|
|
1273
|
+
function riebeckiteSsg(options = {}) {
|
|
1274
|
+
const virtualId = "virtual:riebeckite-ssg-void-entry";
|
|
1275
|
+
const resolvedVirtualId = `\0${virtualId}`;
|
|
1276
|
+
const entry = options.entry ?? defaultEntry;
|
|
1277
|
+
let resolvedConfig;
|
|
1278
|
+
return {
|
|
1279
|
+
name: "riebeckite-ssg",
|
|
1280
|
+
apply: "build",
|
|
1281
|
+
enforce: "post",
|
|
1282
|
+
config() {
|
|
1283
|
+
return {
|
|
1284
|
+
build: {
|
|
1285
|
+
rollupOptions: {
|
|
1286
|
+
input: [virtualId]
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
};
|
|
1290
|
+
},
|
|
1291
|
+
configResolved(config) {
|
|
1292
|
+
resolvedConfig = config;
|
|
1293
|
+
},
|
|
1294
|
+
resolveId(id) {
|
|
1295
|
+
return id === virtualId ? resolvedVirtualId : void 0;
|
|
1296
|
+
},
|
|
1297
|
+
load(id) {
|
|
1298
|
+
return id === resolvedVirtualId ? 'console.log("suppress empty chunk message")' : void 0;
|
|
1299
|
+
},
|
|
1300
|
+
async generateBundle(_outputOptions, bundle) {
|
|
1301
|
+
const config = resolvedConfig;
|
|
1302
|
+
if (!config) {
|
|
1303
|
+
throw new Error("Riebeckite SSG could not resolve the Vite configuration.");
|
|
1304
|
+
}
|
|
1305
|
+
removeVirtualEntryChunk(bundle, resolvedVirtualId);
|
|
1306
|
+
const server2 = await createServer({
|
|
1307
|
+
root: config.root,
|
|
1308
|
+
define: config.define,
|
|
1309
|
+
resolve: {
|
|
1310
|
+
...config.resolve,
|
|
1311
|
+
builtins: [...config.resolve.builtins, /^node:/]
|
|
1312
|
+
},
|
|
1313
|
+
plugins: [],
|
|
1314
|
+
build: { ssr: true },
|
|
1315
|
+
mode: config.mode
|
|
1316
|
+
});
|
|
1317
|
+
try {
|
|
1318
|
+
const module = await server2.ssrLoadModule(entry);
|
|
1319
|
+
const app = module.default;
|
|
1320
|
+
if (!app) {
|
|
1321
|
+
throw new Error(`Failed to find a default export from ${entry}.`);
|
|
1322
|
+
}
|
|
1323
|
+
const generatedHtml = [];
|
|
1324
|
+
const result = await toSSG(
|
|
1325
|
+
app,
|
|
1326
|
+
{
|
|
1327
|
+
writeFile: async (filePath, data) => {
|
|
1328
|
+
const fileName = relative(config.build.outDir, filePath).replaceAll(
|
|
1329
|
+
"\\",
|
|
1330
|
+
"/"
|
|
1331
|
+
);
|
|
1332
|
+
if (fileName.endsWith(".html") && typeof data === "string") {
|
|
1333
|
+
generatedHtml.push({ path: fileName, html: data });
|
|
1334
|
+
}
|
|
1335
|
+
this.emitFile({
|
|
1336
|
+
type: "asset",
|
|
1337
|
+
fileName,
|
|
1338
|
+
source: data
|
|
1339
|
+
});
|
|
1340
|
+
},
|
|
1341
|
+
async mkdir() {
|
|
1342
|
+
}
|
|
1343
|
+
},
|
|
1344
|
+
{
|
|
1345
|
+
dir: config.build.outDir,
|
|
1346
|
+
plugins: options.plugins ?? [],
|
|
1347
|
+
extensionMap: options.extensionMap ?? defaultExtensionMap
|
|
1348
|
+
}
|
|
1349
|
+
);
|
|
1350
|
+
if (!result.success) throw result.error;
|
|
1351
|
+
await emitGeneratedOutputs(
|
|
1352
|
+
module,
|
|
1353
|
+
(asset) => this.emitFile(asset)
|
|
1354
|
+
);
|
|
1355
|
+
inspectGeneratedHtmlPages(module, generatedHtml, {
|
|
1356
|
+
warn: (message) => this.warn(message),
|
|
1357
|
+
info: (message) => this.info(message)
|
|
1358
|
+
});
|
|
1359
|
+
} finally {
|
|
1360
|
+
await server2.close();
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
};
|
|
1409
1364
|
}
|
|
1410
|
-
function
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
" によるもの。すべてのページが翻訳され、既定言語以外は `/lang/` パスで配信され",
|
|
1422
|
-
" ます。各ページには言語スイッチャーが付いています。",
|
|
1423
|
-
"- **エコシステム紹介ページ**(全 7 言語で作成):",
|
|
1424
|
-
" - `/framework/plugins` — 代表的なプラグインを機能別に紹介。",
|
|
1425
|
-
" - `/framework/themes` — 同梱のテーマと切り替え方。",
|
|
1426
|
-
"- **HonoX アプリケーションシェル** `app/` — ルート・コンポーネント・レンダラー",
|
|
1427
|
-
" は自由に拡張できます。",
|
|
1428
|
-
"",
|
|
1429
|
-
"`pnpm dev` を実行してサイトを開いてください。",
|
|
1430
|
-
"",
|
|
1431
|
-
"## コマンド",
|
|
1432
|
-
"",
|
|
1433
|
-
"```sh",
|
|
1434
|
-
"pnpm install",
|
|
1435
|
-
"pnpm exec riebeckite check",
|
|
1436
|
-
"pnpm exec riebeckite dev",
|
|
1437
|
-
"pnpm exec riebeckite build",
|
|
1438
|
-
"```",
|
|
1439
|
-
"",
|
|
1440
|
-
"## ローカライズ",
|
|
1441
|
-
"",
|
|
1442
|
-
"コンテンツは `content/` にプレーンな Markdown として置きます。翻訳ページは既定",
|
|
1443
|
-
"ファイルの隣に `<base>.<lang>.md` の規則で配置します(`about.ja.md`、",
|
|
1444
|
-
"`about.en.md` など)。既定言語は接尾辞なしのパス、それ以外は `/lang/` のパスで",
|
|
1445
|
-
"配信されます。",
|
|
1446
|
-
"",
|
|
1447
|
-
"言語の追加・削除は `riebeckite.config.ts` の `l10n(...)` プラグインを編集し、",
|
|
1448
|
-
"対応する翻訳ファイルを追加・削除してください。",
|
|
1449
|
-
"",
|
|
1450
|
-
"## 拡張",
|
|
1451
|
-
"",
|
|
1452
|
-
`- **プラグイン**: [packages/plugins](${REPO}/tree/main/packages/plugins) を`,
|
|
1453
|
-
" 参照してください。各パッケージにはオプションと例付きの README があります。",
|
|
1454
|
-
"- **テーマ**: このスターターは `@riebeckite/theme-default` を使用しています。",
|
|
1455
|
-
" `riebeckite.config.ts` で別のテーマに差し替えられます。",
|
|
1456
|
-
`- ドキュメント: [English](${REPO}/blob/main/docs/en/README.md)`,
|
|
1457
|
-
` · [日本語](${REPO}/blob/main/docs/ja/README.md)`,
|
|
1458
|
-
""
|
|
1459
|
-
].join("\n");
|
|
1365
|
+
async function emitGeneratedOutputs(module, emit) {
|
|
1366
|
+
const content = module.content;
|
|
1367
|
+
if (!content) return;
|
|
1368
|
+
const manifest = await content.getManifest();
|
|
1369
|
+
for (const output of manifest.generatedOutputs ?? []) {
|
|
1370
|
+
emit({
|
|
1371
|
+
type: "asset",
|
|
1372
|
+
fileName: output.path,
|
|
1373
|
+
source: output.content
|
|
1374
|
+
});
|
|
1375
|
+
}
|
|
1460
1376
|
}
|
|
1461
|
-
function
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
const
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
}
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
`;
|
|
1377
|
+
function inspectGeneratedHtmlPages(module, pages, log) {
|
|
1378
|
+
const plugins = module.config?.plugins ?? [];
|
|
1379
|
+
for (const plugin of plugins) {
|
|
1380
|
+
const inspector = plugin.inspectGeneratedHtml;
|
|
1381
|
+
if (typeof inspector !== "function") continue;
|
|
1382
|
+
for (const page of pages) {
|
|
1383
|
+
for (const diagnostic of inspector(page) ?? []) {
|
|
1384
|
+
const label = `[${plugin.name ?? "plugin"}] ${page.path}: ${diagnostic.message}`;
|
|
1385
|
+
if (diagnostic.severity === "info") log.info(label);
|
|
1386
|
+
else log.warn(label);
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1475
1390
|
}
|
|
1476
|
-
function
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
if (document.readyState === "loading") {
|
|
1483
|
-
document.addEventListener("DOMContentLoaded", initPage, { once: true });
|
|
1484
|
-
} else {
|
|
1485
|
-
initPage();
|
|
1391
|
+
function removeVirtualEntryChunk(bundle, virtualEntryId) {
|
|
1392
|
+
for (const chunk of Object.values(bundle)) {
|
|
1393
|
+
if (chunk.type === "chunk" && chunk.moduleIds?.includes(virtualEntryId)) {
|
|
1394
|
+
delete bundle[chunk.fileName];
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1486
1397
|
}
|
|
1487
1398
|
|
|
1488
|
-
|
|
1489
|
-
|
|
1399
|
+
// src/ssg.ts
|
|
1400
|
+
var defaultSsgEntry = "./app/server.ts";
|
|
1401
|
+
function riebeckiteSsgExtensionMap() {
|
|
1402
|
+
return {
|
|
1403
|
+
"application/atom+xml": "xml",
|
|
1404
|
+
"application/json": "json",
|
|
1405
|
+
"application/rss+xml": "xml",
|
|
1406
|
+
"application/xml": "xml",
|
|
1407
|
+
"text/html": "html",
|
|
1408
|
+
"text/plain": "txt",
|
|
1409
|
+
"text/xml": "xml"
|
|
1410
|
+
};
|
|
1490
1411
|
}
|
|
1491
|
-
|
|
1412
|
+
function createRiebeckiteSsg(options = {}) {
|
|
1413
|
+
return riebeckiteSsg({
|
|
1414
|
+
...options,
|
|
1415
|
+
entry: options.entry ?? defaultSsgEntry,
|
|
1416
|
+
extensionMap: {
|
|
1417
|
+
...riebeckiteSsgExtensionMap(),
|
|
1418
|
+
...options.extensionMap
|
|
1419
|
+
}
|
|
1420
|
+
});
|
|
1492
1421
|
}
|
|
1493
|
-
function appConfig() {
|
|
1494
|
-
return `import path from "node:path";
|
|
1495
|
-
import { fileURLToPath } from "node:url";
|
|
1496
|
-
import { resolveConfigModule } from "@riebeckite/core";
|
|
1497
|
-
import * as rawConfigModule from "../riebeckite.config";
|
|
1498
1422
|
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1423
|
+
// src/vite_runner.ts
|
|
1424
|
+
import fs5 from "node:fs/promises";
|
|
1425
|
+
import path5 from "node:path";
|
|
1426
|
+
import { build, createServer as createServer2 } from "vite";
|
|
1427
|
+
var viteConfigFileNames = [
|
|
1428
|
+
"vite.config.ts",
|
|
1429
|
+
"vite.config.js",
|
|
1430
|
+
"vite.config.mjs"
|
|
1431
|
+
];
|
|
1432
|
+
async function resolveHonoxApplicationRoot(configRoot) {
|
|
1433
|
+
const roots = await findViteApplicationRoots(configRoot);
|
|
1434
|
+
if (roots.length === 1) return roots[0];
|
|
1435
|
+
if (roots.length === 0) {
|
|
1436
|
+
throw new HonoxApplicationRootError(
|
|
1437
|
+
`Could not find a Vite application under ${configRoot}.`
|
|
1438
|
+
);
|
|
1439
|
+
}
|
|
1440
|
+
throw new HonoxApplicationRootError(
|
|
1441
|
+
`Found multiple Vite applications under ${configRoot}: ${roots.join(", ")}.`
|
|
1442
|
+
);
|
|
1512
1443
|
}
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1444
|
+
var HonoxApplicationRootError = class extends Error {
|
|
1445
|
+
constructor(message) {
|
|
1446
|
+
super(message);
|
|
1447
|
+
this.name = "HonoxApplicationRootError";
|
|
1448
|
+
}
|
|
1449
|
+
};
|
|
1450
|
+
async function resolveHonoxApplication(options) {
|
|
1451
|
+
const configRoot = path5.resolve(options.configRoot);
|
|
1452
|
+
const appRoot = options.appRoot ? path5.resolve(options.appRoot) : await resolveHonoxApplicationRoot(configRoot);
|
|
1453
|
+
const workspaceRoot = options.workspaceRoot ?? await findWorkspaceRoot(configRoot);
|
|
1454
|
+
const rawConfig = await loadRiebeckiteConfig({
|
|
1455
|
+
configRoot,
|
|
1456
|
+
configFile: options.configFile,
|
|
1457
|
+
workspaceRoot
|
|
1458
|
+
});
|
|
1459
|
+
const config = resolveHonoxConfig(rawConfig, appRoot);
|
|
1460
|
+
return {
|
|
1522
1461
|
config,
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1462
|
+
configRoot,
|
|
1463
|
+
appRoot,
|
|
1464
|
+
contentRoot: config.content.directory
|
|
1465
|
+
};
|
|
1527
1466
|
}
|
|
1528
|
-
function
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
fileURLToPath(new URL("../../", import.meta.url));
|
|
1536
|
-
|
|
1537
|
-
export const CONTENT_DIR = path.resolve(appRoot, config.content.directory);
|
|
1538
|
-
export const ASSETS_ROOT = "public/";
|
|
1539
|
-
`;
|
|
1467
|
+
async function findWorkspaceRoot(configRoot) {
|
|
1468
|
+
try {
|
|
1469
|
+
const workspaceConfig = path5.join(configRoot, "pnpm-workspace.yaml");
|
|
1470
|
+
return (await fs5.stat(workspaceConfig)).isFile() ? configRoot : void 0;
|
|
1471
|
+
} catch {
|
|
1472
|
+
return void 0;
|
|
1473
|
+
}
|
|
1540
1474
|
}
|
|
1541
|
-
function
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1475
|
+
async function startHonoxDevServer(options) {
|
|
1476
|
+
const server2 = await createServer2({ root: options.root });
|
|
1477
|
+
await server2.listen();
|
|
1478
|
+
server2.printUrls();
|
|
1479
|
+
await waitForShutdown(server2);
|
|
1546
1480
|
}
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1481
|
+
async function buildHonoxApplication(options) {
|
|
1482
|
+
await runTraced(
|
|
1483
|
+
options.tracer,
|
|
1484
|
+
"integration.honox.client_build",
|
|
1485
|
+
() => build({ root: options.root, mode: "client" })
|
|
1486
|
+
);
|
|
1487
|
+
await runTraced(
|
|
1488
|
+
options.tracer,
|
|
1489
|
+
"integration.honox.server_build",
|
|
1490
|
+
() => build({ root: options.root })
|
|
1491
|
+
);
|
|
1556
1492
|
}
|
|
1557
|
-
|
|
1493
|
+
async function runTraced(tracer, name, buildTask) {
|
|
1494
|
+
return tracer ? await tracer.span(name, {}, buildTask) : await buildTask();
|
|
1558
1495
|
}
|
|
1559
|
-
function
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1496
|
+
async function waitForShutdown(server2) {
|
|
1497
|
+
await new Promise((resolve) => {
|
|
1498
|
+
const close = () => {
|
|
1499
|
+
void server2.close().finally(resolve);
|
|
1500
|
+
};
|
|
1501
|
+
process.once("SIGINT", close);
|
|
1502
|
+
process.once("SIGTERM", close);
|
|
1503
|
+
});
|
|
1566
1504
|
}
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1505
|
+
async function findViteApplicationRoots(root) {
|
|
1506
|
+
const directories = [root];
|
|
1507
|
+
const applicationRoots = [];
|
|
1508
|
+
while (directories.length > 0) {
|
|
1509
|
+
const directory = directories.pop();
|
|
1510
|
+
if (!directory) continue;
|
|
1511
|
+
if (await hasViteConfig(directory)) applicationRoots.push(directory);
|
|
1512
|
+
const entries = await fs5.readdir(directory, { withFileTypes: true });
|
|
1513
|
+
for (const entry of entries) {
|
|
1514
|
+
if (!entry.isDirectory() || entry.name === "node_modules" || entry.name === ".git" || entry.name === "tests") {
|
|
1515
|
+
continue;
|
|
1516
|
+
}
|
|
1517
|
+
directories.push(path5.join(directory, entry.name));
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
return applicationRoots;
|
|
1575
1521
|
}
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1522
|
+
async function hasViteConfig(directory) {
|
|
1523
|
+
for (const fileName of viteConfigFileNames) {
|
|
1524
|
+
try {
|
|
1525
|
+
if ((await fs5.stat(path5.join(directory, fileName))).isFile()) return true;
|
|
1526
|
+
} catch {
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
return false;
|
|
1581
1530
|
}
|
|
1582
1531
|
|
|
1583
|
-
.
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1532
|
+
// src/vite_plugin.ts
|
|
1533
|
+
var defaultSsrExternals = [
|
|
1534
|
+
"extend",
|
|
1535
|
+
"debug",
|
|
1536
|
+
"node:fs/promises",
|
|
1537
|
+
"node:path",
|
|
1538
|
+
"parse-numeric-range",
|
|
1539
|
+
"slugify",
|
|
1540
|
+
"vfile-matter",
|
|
1541
|
+
"yaml"
|
|
1542
|
+
];
|
|
1543
|
+
function riebeckite(options = {}) {
|
|
1544
|
+
let resolvedConfig;
|
|
1545
|
+
const getConfig = () => {
|
|
1546
|
+
if (!resolvedConfig) {
|
|
1547
|
+
throw new Error("Riebeckite config has not been loaded yet.");
|
|
1548
|
+
}
|
|
1549
|
+
return resolvedConfig;
|
|
1550
|
+
};
|
|
1551
|
+
return [
|
|
1552
|
+
{
|
|
1553
|
+
name: "riebeckite-host-integration",
|
|
1554
|
+
async config(userConfig) {
|
|
1555
|
+
const root = userConfig.root ? path6.resolve(userConfig.root) : process.cwd();
|
|
1556
|
+
const appRoot = options.appRoot ?? root;
|
|
1557
|
+
const application = await resolveHonoxApplication({
|
|
1558
|
+
configRoot: options.configRoot ?? appRoot,
|
|
1559
|
+
configFile: options.configFile,
|
|
1560
|
+
appRoot,
|
|
1561
|
+
workspaceRoot: options.workspaceRoot
|
|
1562
|
+
});
|
|
1563
|
+
resolvedConfig = application.config;
|
|
1564
|
+
writeRiebeckiteAssetEntries(resolvedConfig, {
|
|
1565
|
+
pluginStyles: path6.join(appRoot, "app/.riebeckite/plugin-styles.css"),
|
|
1566
|
+
themeStyles: path6.join(appRoot, "app/.riebeckite/theme-styles.css")
|
|
1567
|
+
});
|
|
1568
|
+
return {
|
|
1569
|
+
define: {
|
|
1570
|
+
"process.env.RIEBECKITE_APP_ROOT": JSON.stringify(appRoot)
|
|
1571
|
+
},
|
|
1572
|
+
resolve: {
|
|
1573
|
+
alias: options.workspaceRoot ? createWorkspacePackageAliases(options.workspaceRoot) : []
|
|
1574
|
+
}
|
|
1575
|
+
};
|
|
1576
|
+
}
|
|
1577
|
+
},
|
|
1578
|
+
riebeckiteClientModule(getConfig)
|
|
1579
|
+
];
|
|
1590
1580
|
}
|
|
1591
|
-
function
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
<a href="/" class="site-header__home">
|
|
1599
|
-
{config.site.title}
|
|
1600
|
-
</a>
|
|
1601
|
-
<ColorModeToggle />
|
|
1602
|
-
</header>
|
|
1603
|
-
);
|
|
1581
|
+
function riebeckiteVite(options = {}) {
|
|
1582
|
+
const { ssg, ssrExternals, ...integration } = options;
|
|
1583
|
+
return [
|
|
1584
|
+
...riebeckite(integration),
|
|
1585
|
+
riebeckiteSsrExternals([...defaultSsrExternals, ...ssrExternals ?? []]),
|
|
1586
|
+
createRiebeckiteSsg(ssg)
|
|
1587
|
+
];
|
|
1604
1588
|
}
|
|
1605
|
-
|
|
1589
|
+
function riebeckiteSsrExternals(externals) {
|
|
1590
|
+
return {
|
|
1591
|
+
name: "riebeckite-ssr-externals",
|
|
1592
|
+
config() {
|
|
1593
|
+
return {
|
|
1594
|
+
environments: {
|
|
1595
|
+
ssr: {
|
|
1596
|
+
resolve: {
|
|
1597
|
+
external: [...externals]
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
};
|
|
1602
|
+
}
|
|
1603
|
+
};
|
|
1606
1604
|
}
|
|
1607
|
-
function article() {
|
|
1608
|
-
return `import type { PostContent } from "@riebeckite/core";
|
|
1609
|
-
import { Article, ArticleContent, ArticleLayout } from "@riebeckite/honox/ui";
|
|
1610
1605
|
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1606
|
+
// src/scaffold/templates.ts
|
|
1607
|
+
function siteTemplateFiles(variables) {
|
|
1608
|
+
return [
|
|
1609
|
+
{ path: "package.json", content: packageJson(variables) },
|
|
1610
|
+
{ path: "riebeckite.config.ts", content: riebeckiteConfig(variables) },
|
|
1611
|
+
{ path: "vite.config.ts", content: viteConfig() },
|
|
1612
|
+
{ path: "tsconfig.json", content: tsconfig() },
|
|
1613
|
+
{ path: ".gitignore", content: gitignore() },
|
|
1614
|
+
{ path: "README.md", content: readme(variables) },
|
|
1615
|
+
...localizedContentFiles(variables),
|
|
1616
|
+
{ path: "app/server.ts", content: server() },
|
|
1617
|
+
{ path: "app/client.ts", content: client() },
|
|
1618
|
+
{ path: "app/config.ts", content: appConfig() },
|
|
1619
|
+
{ path: "app/content.ts", content: appContent() },
|
|
1620
|
+
{ path: "app/constants/paths.ts", content: paths() },
|
|
1621
|
+
{ path: "app/global.d.ts", content: globalDeclarations() },
|
|
1622
|
+
{ path: "app/style.css", content: style() },
|
|
1623
|
+
{ path: "app/components/site-header.tsx", content: siteHeader() },
|
|
1624
|
+
{ path: "app/components/article.tsx", content: article() },
|
|
1625
|
+
{ path: "app/routes/_renderer.tsx", content: renderer() },
|
|
1626
|
+
{ path: "app/routes/index.tsx", content: indexRoute() },
|
|
1627
|
+
{ path: "app/routes/[slug{.+}].tsx", content: slugRoute() }
|
|
1628
|
+
];
|
|
1633
1629
|
}
|
|
1630
|
+
function packageJson(variables) {
|
|
1631
|
+
return `${JSON.stringify(
|
|
1632
|
+
{
|
|
1633
|
+
name: variables.name,
|
|
1634
|
+
private: true,
|
|
1635
|
+
version: "0.0.0",
|
|
1636
|
+
type: "module",
|
|
1637
|
+
scripts: {
|
|
1638
|
+
dev: "riebeckite dev",
|
|
1639
|
+
build: "riebeckite build",
|
|
1640
|
+
check: "riebeckite check",
|
|
1641
|
+
doctor: "riebeckite doctor",
|
|
1642
|
+
inspect: "riebeckite inspect"
|
|
1643
|
+
},
|
|
1644
|
+
dependencies: {
|
|
1645
|
+
"@riebeckite/core": "^0.0.3",
|
|
1646
|
+
"@riebeckite/honox": "^0.0.3",
|
|
1647
|
+
"@riebeckite/plugin-color-mode": "^0.0.3",
|
|
1648
|
+
"@riebeckite/plugin-l10n": "^0.0.3",
|
|
1649
|
+
"@riebeckite/plugin-obsidian-markdown": "^0.0.3",
|
|
1650
|
+
"@riebeckite/theme-default": "^0.0.3",
|
|
1651
|
+
hono: "^4.12.25",
|
|
1652
|
+
honox: "0.1.56"
|
|
1653
|
+
},
|
|
1654
|
+
devDependencies: {
|
|
1655
|
+
"@hono/vite-build": "^1.11.1",
|
|
1656
|
+
"@riebeckite/cli": "^0.0.3",
|
|
1657
|
+
"@types/node": "^24.5.2",
|
|
1658
|
+
typescript: "^5.0.0",
|
|
1659
|
+
vite: "^8.0.9"
|
|
1660
|
+
}
|
|
1661
|
+
},
|
|
1662
|
+
null,
|
|
1663
|
+
2
|
|
1664
|
+
)}
|
|
1634
1665
|
`;
|
|
1635
1666
|
}
|
|
1636
|
-
function
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
import {
|
|
1640
|
-
import {
|
|
1641
|
-
import {
|
|
1642
|
-
import {
|
|
1643
|
-
|
|
1644
|
-
function themeAttributes() {
|
|
1645
|
-
const { theme } = config;
|
|
1667
|
+
function riebeckiteConfig(variables) {
|
|
1668
|
+
const { title, description, baseUrl, locale } = variables;
|
|
1669
|
+
const languages = ["en", "ja", "zh-CN", "es", "de", "fr", "ko"];
|
|
1670
|
+
return `import { defineConfig } from "@riebeckite/core";
|
|
1671
|
+
import { colorModePlugin } from "@riebeckite/plugin-color-mode";
|
|
1672
|
+
import { l10n } from "@riebeckite/plugin-l10n";
|
|
1673
|
+
import { obsidianMarkdown } from "@riebeckite/plugin-obsidian-markdown";
|
|
1674
|
+
import { defaultTheme } from "@riebeckite/theme-default";
|
|
1646
1675
|
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
}
|
|
1676
|
+
export default defineConfig({
|
|
1677
|
+
site: {
|
|
1678
|
+
title: ${JSON.stringify(title)},
|
|
1679
|
+
description: ${JSON.stringify(description)},
|
|
1680
|
+
baseUrl: ${JSON.stringify(baseUrl)},
|
|
1681
|
+
locale: ${JSON.stringify(locale)},
|
|
1682
|
+
},
|
|
1683
|
+
content: {
|
|
1684
|
+
directory: "content",
|
|
1685
|
+
},
|
|
1686
|
+
theme: defaultTheme(),
|
|
1687
|
+
plugins: [
|
|
1688
|
+
obsidianMarkdown(),
|
|
1689
|
+
colorModePlugin(),
|
|
1690
|
+
l10n({
|
|
1691
|
+
defaultLang: ${JSON.stringify(defaultLanguageForLocale(locale))},
|
|
1692
|
+
languages: ${JSON.stringify(languages)},
|
|
1693
|
+
}),
|
|
1694
|
+
],
|
|
1695
|
+
});
|
|
1696
|
+
`;
|
|
1654
1697
|
}
|
|
1698
|
+
function viteConfig() {
|
|
1699
|
+
const ssrExternals = [...defaultSsrExternals].map((name) => ` "${name}",`).join("\n");
|
|
1700
|
+
return `import path from "node:path";
|
|
1701
|
+
import { fileURLToPath } from "node:url";
|
|
1702
|
+
import build from "@hono/vite-build/node";
|
|
1703
|
+
import {
|
|
1704
|
+
riebeckite,
|
|
1705
|
+
riebeckiteSsg,
|
|
1706
|
+
riebeckiteSsgExtensionMap,
|
|
1707
|
+
} from "@riebeckite/honox";
|
|
1708
|
+
import honox from "honox/vite";
|
|
1709
|
+
import { defineConfig } from "vite";
|
|
1655
1710
|
|
|
1656
|
-
|
|
1657
|
-
const headTags: readonly PluginHeadTag[] = c.get("headTags") ?? [];
|
|
1711
|
+
const appRoot = fileURLToPath(new URL(".", import.meta.url));
|
|
1658
1712
|
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
{
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1713
|
+
export default defineConfig({
|
|
1714
|
+
plugins: [
|
|
1715
|
+
honox({
|
|
1716
|
+
client: { input: ["/app/client.ts", "/app/style.css"] },
|
|
1717
|
+
}),
|
|
1718
|
+
riebeckite({ appRoot }),
|
|
1719
|
+
build(),
|
|
1720
|
+
riebeckiteSsg({
|
|
1721
|
+
entry: path.join(appRoot, "app/server.ts"),
|
|
1722
|
+
extensionMap: riebeckiteSsgExtensionMap(),
|
|
1723
|
+
}),
|
|
1724
|
+
],
|
|
1725
|
+
environments: {
|
|
1726
|
+
ssr: {
|
|
1727
|
+
resolve: {
|
|
1728
|
+
external: [
|
|
1729
|
+
${ssrExternals}
|
|
1730
|
+
],
|
|
1731
|
+
},
|
|
1732
|
+
},
|
|
1733
|
+
},
|
|
1679
1734
|
});
|
|
1680
|
-
|
|
1681
|
-
function renderHeadTag(tag: PluginHeadTag, index: number) {
|
|
1682
|
-
const key = \`\${tag.tag}-\${index}\`;
|
|
1683
|
-
if (tag.tag === "meta") return <meta {...tag.attrs} key={key} />;
|
|
1684
|
-
if (tag.tag === "link") return <link {...tag.attrs} key={key} />;
|
|
1685
|
-
return (
|
|
1686
|
-
<script
|
|
1687
|
-
{...tag.attrs}
|
|
1688
|
-
key={key}
|
|
1689
|
-
dangerouslySetInnerHTML={
|
|
1690
|
-
tag.children ? { __html: tag.children } : undefined
|
|
1691
|
-
}
|
|
1692
|
-
/>
|
|
1693
|
-
);
|
|
1735
|
+
`;
|
|
1694
1736
|
}
|
|
1737
|
+
function tsconfig() {
|
|
1738
|
+
return `${JSON.stringify(
|
|
1739
|
+
{
|
|
1740
|
+
compilerOptions: {
|
|
1741
|
+
target: "ES2022",
|
|
1742
|
+
module: "ESNext",
|
|
1743
|
+
moduleResolution: "Bundler",
|
|
1744
|
+
lib: ["ES2022", "DOM", "DOM.Iterable"],
|
|
1745
|
+
jsx: "react-jsx",
|
|
1746
|
+
jsxImportSource: "hono/jsx",
|
|
1747
|
+
types: ["node", "vite/client"],
|
|
1748
|
+
strict: true,
|
|
1749
|
+
noEmit: true,
|
|
1750
|
+
esModuleInterop: true,
|
|
1751
|
+
allowSyntheticDefaultImports: true,
|
|
1752
|
+
resolveJsonModule: true,
|
|
1753
|
+
skipLibCheck: true
|
|
1754
|
+
},
|
|
1755
|
+
include: [
|
|
1756
|
+
"app/**/*.ts",
|
|
1757
|
+
"app/**/*.tsx",
|
|
1758
|
+
"riebeckite.config.ts",
|
|
1759
|
+
"vite.config.ts"
|
|
1760
|
+
]
|
|
1761
|
+
},
|
|
1762
|
+
null,
|
|
1763
|
+
2
|
|
1764
|
+
)}
|
|
1695
1765
|
`;
|
|
1696
1766
|
}
|
|
1697
|
-
function
|
|
1698
|
-
return
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
}
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1767
|
+
function gitignore() {
|
|
1768
|
+
return ["node_modules/", "dist/", ".riebeckite/", ""].join("\n");
|
|
1769
|
+
}
|
|
1770
|
+
function readme(variables) {
|
|
1771
|
+
return defaultLanguageForLocale(variables.locale) === "ja" ? jaReadme(variables) : enReadme(variables);
|
|
1772
|
+
}
|
|
1773
|
+
var REPO = "https://github.com/Rerurate514/riebeckite";
|
|
1774
|
+
function enReadme(variables) {
|
|
1775
|
+
return [
|
|
1776
|
+
`# ${variables.title}`,
|
|
1777
|
+
"",
|
|
1778
|
+
"A multilingual Riebeckite site generated by `riebeckite init` — seven",
|
|
1779
|
+
"languages out of the box, plus a tour of the plugin and theme ecosystem.",
|
|
1780
|
+
"",
|
|
1781
|
+
"## What's inside",
|
|
1782
|
+
"",
|
|
1783
|
+
"- **Seven languages** (`en`, `ja`, `zh-CN`, `es`, `de`, `fr`, `ko`) via",
|
|
1784
|
+
` [\`@riebeckite/plugin-l10n\`](${REPO}/blob/main/packages/plugins/l10n/README.md).`,
|
|
1785
|
+
" Every page is translated; non-default languages are served under `/lang/`",
|
|
1786
|
+
" paths, and each page carries a language switcher.",
|
|
1787
|
+
"- **Ecosystem tour pages**, written in all seven languages:",
|
|
1788
|
+
" - `/framework/plugins` — representative plugins grouped by capability.",
|
|
1789
|
+
" - `/framework/themes` — the bundled themes and how to switch.",
|
|
1790
|
+
"- The **HonoX application shell** under `app/` — routes, components, and the",
|
|
1791
|
+
" renderer are yours to extend.",
|
|
1792
|
+
"",
|
|
1793
|
+
"Run `pnpm dev` and open the site to explore.",
|
|
1794
|
+
"",
|
|
1795
|
+
"## Commands",
|
|
1796
|
+
"",
|
|
1797
|
+
"```sh",
|
|
1798
|
+
"pnpm install",
|
|
1799
|
+
"pnpm exec riebeckite check",
|
|
1800
|
+
"pnpm exec riebeckite dev",
|
|
1801
|
+
"pnpm exec riebeckite build",
|
|
1802
|
+
"```",
|
|
1803
|
+
"",
|
|
1804
|
+
"## Localization",
|
|
1805
|
+
"",
|
|
1806
|
+
"Content lives in `content/` as plain Markdown. Translations sit next to the",
|
|
1807
|
+
"default file using the `<base>.<lang>.md` convention (`about.ja.md`,",
|
|
1808
|
+
"`about.en.md`). The default language keeps the unsuffixed path; the rest are",
|
|
1809
|
+
"served under `/lang/`.",
|
|
1810
|
+
"",
|
|
1811
|
+
"To add or remove a language, edit the `l10n(...)` plugin in",
|
|
1812
|
+
"`riebeckite.config.ts` and add or remove the matching translation files.",
|
|
1813
|
+
"",
|
|
1814
|
+
"## Extending",
|
|
1815
|
+
"",
|
|
1816
|
+
`- **Plugins**: browse [packages/plugins](${REPO}/tree/main/packages/plugins)`,
|
|
1817
|
+
" in the Riebeckite repository — each package has its own README with options",
|
|
1818
|
+
" and examples.",
|
|
1819
|
+
"- **Themes**: this starter uses `@riebeckite/theme-default`; swap it for",
|
|
1820
|
+
" another theme in `riebeckite.config.ts`.",
|
|
1821
|
+
`- Docs: [English](${REPO}/blob/main/docs/en/README.md)`,
|
|
1822
|
+
` · [日本語](${REPO}/blob/main/docs/ja/README.md)`,
|
|
1823
|
+
""
|
|
1824
|
+
].join("\n");
|
|
1825
|
+
}
|
|
1826
|
+
function jaReadme(variables) {
|
|
1827
|
+
return [
|
|
1828
|
+
`# ${variables.title}`,
|
|
1829
|
+
"",
|
|
1830
|
+
"`riebeckite init` で生成した多言語対応の Riebeckite サイトです。7 言語に対応し、",
|
|
1831
|
+
"プラグインとテーマのエコシステムを体感できる構成になっています。",
|
|
1832
|
+
"",
|
|
1833
|
+
"## 含まれているもの",
|
|
1834
|
+
"",
|
|
1835
|
+
"- **7 言語対応**(`en`, `ja`, `zh-CN`, `es`, `de`, `fr`, `ko`)—",
|
|
1836
|
+
` [\`@riebeckite/plugin-l10n\`](${REPO}/blob/main/packages/plugins/l10n/README_ja.md)`,
|
|
1837
|
+
" によるもの。すべてのページが翻訳され、既定言語以外は `/lang/` パスで配信され",
|
|
1838
|
+
" ます。各ページには言語スイッチャーが付いています。",
|
|
1839
|
+
"- **エコシステム紹介ページ**(全 7 言語で作成):",
|
|
1840
|
+
" - `/framework/plugins` — 代表的なプラグインを機能別に紹介。",
|
|
1841
|
+
" - `/framework/themes` — 同梱のテーマと切り替え方。",
|
|
1842
|
+
"- **HonoX アプリケーションシェル** `app/` — ルート・コンポーネント・レンダラー",
|
|
1843
|
+
" は自由に拡張できます。",
|
|
1844
|
+
"",
|
|
1845
|
+
"`pnpm dev` を実行してサイトを開いてください。",
|
|
1846
|
+
"",
|
|
1847
|
+
"## コマンド",
|
|
1848
|
+
"",
|
|
1849
|
+
"```sh",
|
|
1850
|
+
"pnpm install",
|
|
1851
|
+
"pnpm exec riebeckite check",
|
|
1852
|
+
"pnpm exec riebeckite dev",
|
|
1853
|
+
"pnpm exec riebeckite build",
|
|
1854
|
+
"```",
|
|
1855
|
+
"",
|
|
1856
|
+
"## ローカライズ",
|
|
1857
|
+
"",
|
|
1858
|
+
"コンテンツは `content/` にプレーンな Markdown として置きます。翻訳ページは既定",
|
|
1859
|
+
"ファイルの隣に `<base>.<lang>.md` の規則で配置します(`about.ja.md`、",
|
|
1860
|
+
"`about.en.md` など)。既定言語は接尾辞なしのパス、それ以外は `/lang/` のパスで",
|
|
1861
|
+
"配信されます。",
|
|
1862
|
+
"",
|
|
1863
|
+
"言語の追加・削除は `riebeckite.config.ts` の `l10n(...)` プラグインを編集し、",
|
|
1864
|
+
"対応する翻訳ファイルを追加・削除してください。",
|
|
1865
|
+
"",
|
|
1866
|
+
"## 拡張",
|
|
1867
|
+
"",
|
|
1868
|
+
`- **プラグイン**: [packages/plugins](${REPO}/tree/main/packages/plugins) を`,
|
|
1869
|
+
" 参照してください。各パッケージにはオプションと例付きの README があります。",
|
|
1870
|
+
"- **テーマ**: このスターターは `@riebeckite/theme-default` を使用しています。",
|
|
1871
|
+
" `riebeckite.config.ts` で別のテーマに差し替えられます。",
|
|
1872
|
+
`- ドキュメント: [English](${REPO}/blob/main/docs/en/README.md)`,
|
|
1873
|
+
` · [日本語](${REPO}/blob/main/docs/ja/README.md)`,
|
|
1874
|
+
""
|
|
1875
|
+
].join("\n");
|
|
1876
|
+
}
|
|
1877
|
+
function server() {
|
|
1878
|
+
return `import { mountRiebeckiteEndpoints } from "@riebeckite/honox/server";
|
|
1879
|
+
import { createApp } from "honox/server";
|
|
1880
|
+
import { config } from "./config";
|
|
1881
|
+
import { content } from "./content";
|
|
1720
1882
|
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
/>,
|
|
1726
|
-
);
|
|
1883
|
+
const app = createApp({
|
|
1884
|
+
init: (app) => {
|
|
1885
|
+
mountRiebeckiteEndpoints(app, { config, content });
|
|
1886
|
+
},
|
|
1727
1887
|
});
|
|
1888
|
+
|
|
1889
|
+
export default app;
|
|
1728
1890
|
`;
|
|
1729
1891
|
}
|
|
1730
|
-
function
|
|
1731
|
-
return `import {
|
|
1732
|
-
import {
|
|
1733
|
-
contentRouteSsgParams,
|
|
1734
|
-
resolveContentRoute,
|
|
1735
|
-
} from "@riebeckite/honox/server";
|
|
1736
|
-
import { createRoute } from "honox/factory";
|
|
1737
|
-
import { SiteArticle } from "../components/article";
|
|
1738
|
-
import { config } from "../config";
|
|
1739
|
-
import { content } from "../content";
|
|
1892
|
+
function client() {
|
|
1893
|
+
return `import { initRiebeckiteClient } from "virtual:riebeckite/client";
|
|
1894
|
+
import { createClient } from "honox/client";
|
|
1740
1895
|
|
|
1741
|
-
|
|
1742
|
-
contentRouteSsgParams("/:slug{.+}", async () => {
|
|
1743
|
-
const manifest = await content.getManifest();
|
|
1744
|
-
return manifest.entries
|
|
1745
|
-
.filter((entry) => isPublished(config, entry.frontmatter))
|
|
1746
|
-
.filter((entry) => entry.permalink !== "/")
|
|
1747
|
-
.map((entry) => ({ slug: entry.permalink.replace(/^\\/+/, "") }));
|
|
1748
|
-
}),
|
|
1749
|
-
async (c) => {
|
|
1750
|
-
const requestedSlug = c.req.param("slug");
|
|
1751
|
-
if (!requestedSlug) return c.notFound();
|
|
1752
|
-
if (/\\.[a-zA-Z0-9]+$/.test(requestedSlug)) return c.notFound();
|
|
1896
|
+
createClient();
|
|
1753
1897
|
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1898
|
+
if (document.readyState === "loading") {
|
|
1899
|
+
document.addEventListener("DOMContentLoaded", initPage, { once: true });
|
|
1900
|
+
} else {
|
|
1901
|
+
initPage();
|
|
1902
|
+
}
|
|
1759
1903
|
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1904
|
+
function initPage() {
|
|
1905
|
+
initRiebeckiteClient();
|
|
1906
|
+
}
|
|
1907
|
+
`;
|
|
1908
|
+
}
|
|
1909
|
+
function appConfig() {
|
|
1910
|
+
return `import path from "node:path";
|
|
1911
|
+
import { fileURLToPath } from "node:url";
|
|
1912
|
+
import { resolveConfigModule } from "@riebeckite/core";
|
|
1913
|
+
import * as rawConfigModule from "../riebeckite.config";
|
|
1764
1914
|
|
|
1765
|
-
|
|
1766
|
-
|
|
1915
|
+
const appRoot =
|
|
1916
|
+
process.env.RIEBECKITE_APP_ROOT ??
|
|
1917
|
+
fileURLToPath(new URL("../", import.meta.url));
|
|
1918
|
+
const resolvedConfig = resolveConfigModule(rawConfigModule);
|
|
1767
1919
|
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
);
|
|
1920
|
+
export const config = {
|
|
1921
|
+
...resolvedConfig,
|
|
1922
|
+
content: {
|
|
1923
|
+
...resolvedConfig.content,
|
|
1924
|
+
directory: path.resolve(appRoot, resolvedConfig.content.directory),
|
|
1774
1925
|
},
|
|
1775
|
-
|
|
1926
|
+
};
|
|
1776
1927
|
`;
|
|
1777
1928
|
}
|
|
1929
|
+
function appContent() {
|
|
1930
|
+
return `import { ContentManager } from "@riebeckite/core";
|
|
1931
|
+
import { config } from "./config";
|
|
1932
|
+
import { CONTENT_DIR } from "./constants/paths";
|
|
1778
1933
|
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
}
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
const files = siteTemplateFiles(templateVariables(options, targetDirectory));
|
|
1789
|
-
await assertTargetWritable(
|
|
1790
|
-
targetDirectory,
|
|
1791
|
-
files,
|
|
1792
|
-
options.overwrite ?? false
|
|
1793
|
-
);
|
|
1794
|
-
for (const file of files) {
|
|
1795
|
-
const filePath = path4.join(targetDirectory, file.path);
|
|
1796
|
-
await fs4.mkdir(path4.dirname(filePath), { recursive: true });
|
|
1797
|
-
await fs4.writeFile(filePath, file.content, "utf8");
|
|
1798
|
-
}
|
|
1799
|
-
return { targetDirectory, files: files.map((file) => file.path) };
|
|
1800
|
-
}
|
|
1801
|
-
function templateVariables(options, targetDirectory) {
|
|
1802
|
-
const name = normalizePackageName(
|
|
1803
|
-
options.name ?? path4.basename(targetDirectory)
|
|
1804
|
-
);
|
|
1805
|
-
return {
|
|
1806
|
-
name,
|
|
1807
|
-
title: options.siteTitle ?? name,
|
|
1808
|
-
description: options.description ?? "",
|
|
1809
|
-
baseUrl: options.baseUrl ?? "",
|
|
1810
|
-
locale: options.locale ?? "en"
|
|
1811
|
-
};
|
|
1812
|
-
}
|
|
1813
|
-
async function assertTargetWritable(targetDirectory, files, overwrite) {
|
|
1814
|
-
let entries;
|
|
1815
|
-
try {
|
|
1816
|
-
entries = await fs4.readdir(targetDirectory);
|
|
1817
|
-
} catch (error) {
|
|
1818
|
-
if (isNotFoundError(error)) return;
|
|
1819
|
-
throw error;
|
|
1820
|
-
}
|
|
1821
|
-
const conflicts = entries.filter(
|
|
1822
|
-
(entry) => files.some((file) => file.path.split("/")[0] === entry)
|
|
1823
|
-
);
|
|
1824
|
-
if (conflicts.length === 0) return;
|
|
1825
|
-
if (overwrite) return;
|
|
1826
|
-
throw new ScaffoldSiteError(
|
|
1827
|
-
`The target directory is not empty: ${targetDirectory}
|
|
1828
|
-
Existing entries: ${conflicts.slice(0, 5).join(", ")}
|
|
1829
|
-
Pass --force to overwrite generated files.`
|
|
1830
|
-
);
|
|
1831
|
-
}
|
|
1832
|
-
function normalizePackageName(value) {
|
|
1833
|
-
const normalized = value.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[-_.]+/, "").replace(/[-_.]+$/, "");
|
|
1834
|
-
return normalized || "riebeckite-site";
|
|
1835
|
-
}
|
|
1836
|
-
function isNotFoundError(error) {
|
|
1837
|
-
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
1934
|
+
export const content = new ContentManager(
|
|
1935
|
+
CONTENT_DIR,
|
|
1936
|
+
config.content.exclude,
|
|
1937
|
+
{
|
|
1938
|
+
config,
|
|
1939
|
+
plugins: config.plugins,
|
|
1940
|
+
},
|
|
1941
|
+
);
|
|
1942
|
+
`;
|
|
1838
1943
|
}
|
|
1944
|
+
function paths() {
|
|
1945
|
+
return `import path from "node:path";
|
|
1946
|
+
import { fileURLToPath } from "node:url";
|
|
1947
|
+
import { config } from "../config";
|
|
1839
1948
|
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
const resolvedVirtualId = `\0${virtualId}`;
|
|
1848
|
-
const entry = options.entry ?? defaultEntry;
|
|
1849
|
-
let resolvedConfig;
|
|
1850
|
-
return {
|
|
1851
|
-
name: "riebeckite-ssg",
|
|
1852
|
-
apply: "build",
|
|
1853
|
-
enforce: "post",
|
|
1854
|
-
config() {
|
|
1855
|
-
return {
|
|
1856
|
-
build: {
|
|
1857
|
-
rollupOptions: {
|
|
1858
|
-
input: [virtualId]
|
|
1859
|
-
}
|
|
1860
|
-
}
|
|
1861
|
-
};
|
|
1862
|
-
},
|
|
1863
|
-
configResolved(config) {
|
|
1864
|
-
resolvedConfig = config;
|
|
1865
|
-
},
|
|
1866
|
-
resolveId(id) {
|
|
1867
|
-
return id === virtualId ? resolvedVirtualId : void 0;
|
|
1868
|
-
},
|
|
1869
|
-
load(id) {
|
|
1870
|
-
return id === resolvedVirtualId ? 'console.log("suppress empty chunk message")' : void 0;
|
|
1871
|
-
},
|
|
1872
|
-
async generateBundle(_outputOptions, bundle) {
|
|
1873
|
-
const config = resolvedConfig;
|
|
1874
|
-
if (!config) {
|
|
1875
|
-
throw new Error("Riebeckite SSG could not resolve the Vite configuration.");
|
|
1876
|
-
}
|
|
1877
|
-
removeVirtualEntryChunk(bundle, resolvedVirtualId);
|
|
1878
|
-
const server2 = await createServer({
|
|
1879
|
-
root: config.root,
|
|
1880
|
-
define: config.define,
|
|
1881
|
-
resolve: {
|
|
1882
|
-
...config.resolve,
|
|
1883
|
-
builtins: [...config.resolve.builtins, /^node:/]
|
|
1884
|
-
},
|
|
1885
|
-
plugins: [],
|
|
1886
|
-
build: { ssr: true },
|
|
1887
|
-
mode: config.mode
|
|
1888
|
-
});
|
|
1889
|
-
try {
|
|
1890
|
-
const module = await server2.ssrLoadModule(entry);
|
|
1891
|
-
const app = module.default;
|
|
1892
|
-
if (!app) {
|
|
1893
|
-
throw new Error(`Failed to find a default export from ${entry}.`);
|
|
1894
|
-
}
|
|
1895
|
-
const generatedHtml = [];
|
|
1896
|
-
const result = await toSSG(
|
|
1897
|
-
app,
|
|
1898
|
-
{
|
|
1899
|
-
writeFile: async (filePath, data) => {
|
|
1900
|
-
const fileName = relative(config.build.outDir, filePath).replaceAll(
|
|
1901
|
-
"\\",
|
|
1902
|
-
"/"
|
|
1903
|
-
);
|
|
1904
|
-
if (fileName.endsWith(".html") && typeof data === "string") {
|
|
1905
|
-
generatedHtml.push({ path: fileName, html: data });
|
|
1906
|
-
}
|
|
1907
|
-
this.emitFile({
|
|
1908
|
-
type: "asset",
|
|
1909
|
-
fileName,
|
|
1910
|
-
source: data
|
|
1911
|
-
});
|
|
1912
|
-
},
|
|
1913
|
-
async mkdir() {
|
|
1914
|
-
}
|
|
1915
|
-
},
|
|
1916
|
-
{
|
|
1917
|
-
dir: config.build.outDir,
|
|
1918
|
-
plugins: options.plugins ?? [],
|
|
1919
|
-
extensionMap: options.extensionMap ?? defaultExtensionMap
|
|
1920
|
-
}
|
|
1921
|
-
);
|
|
1922
|
-
if (!result.success) throw result.error;
|
|
1923
|
-
await emitGeneratedOutputs(
|
|
1924
|
-
module,
|
|
1925
|
-
(asset) => this.emitFile(asset)
|
|
1926
|
-
);
|
|
1927
|
-
inspectGeneratedHtmlPages(module, generatedHtml, {
|
|
1928
|
-
warn: (message) => this.warn(message),
|
|
1929
|
-
info: (message) => this.info(message)
|
|
1930
|
-
});
|
|
1931
|
-
} finally {
|
|
1932
|
-
await server2.close();
|
|
1933
|
-
}
|
|
1934
|
-
}
|
|
1935
|
-
};
|
|
1936
|
-
}
|
|
1937
|
-
async function emitGeneratedOutputs(module, emit) {
|
|
1938
|
-
const content = module.content;
|
|
1939
|
-
if (!content) return;
|
|
1940
|
-
const manifest = await content.getManifest();
|
|
1941
|
-
for (const output of manifest.generatedOutputs ?? []) {
|
|
1942
|
-
emit({
|
|
1943
|
-
type: "asset",
|
|
1944
|
-
fileName: output.path,
|
|
1945
|
-
source: output.content
|
|
1946
|
-
});
|
|
1947
|
-
}
|
|
1949
|
+
const appRoot =
|
|
1950
|
+
process.env.RIEBECKITE_APP_ROOT ??
|
|
1951
|
+
fileURLToPath(new URL("../../", import.meta.url));
|
|
1952
|
+
|
|
1953
|
+
export const CONTENT_DIR = path.resolve(appRoot, config.content.directory);
|
|
1954
|
+
export const ASSETS_ROOT = "public/";
|
|
1955
|
+
`;
|
|
1948
1956
|
}
|
|
1949
|
-
function
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
for (const page of pages) {
|
|
1955
|
-
for (const diagnostic of inspector(page) ?? []) {
|
|
1956
|
-
const label = `[${plugin.name ?? "plugin"}] ${page.path}: ${diagnostic.message}`;
|
|
1957
|
-
if (diagnostic.severity === "info") log.info(label);
|
|
1958
|
-
else log.warn(label);
|
|
1959
|
-
}
|
|
1960
|
-
}
|
|
1961
|
-
}
|
|
1957
|
+
function globalDeclarations() {
|
|
1958
|
+
return `import type { PluginHeadTag } from "@riebeckite/core";
|
|
1959
|
+
|
|
1960
|
+
declare module "virtual:riebeckite/client" {
|
|
1961
|
+
export function initRiebeckiteClient(): void;
|
|
1962
1962
|
}
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1963
|
+
|
|
1964
|
+
declare module "hono" {
|
|
1965
|
+
interface Env {
|
|
1966
|
+
Variables: {
|
|
1967
|
+
headTags?: readonly PluginHeadTag[];
|
|
1968
|
+
htmlLanguage?: string;
|
|
1969
|
+
};
|
|
1970
|
+
Bindings: Record<string, never>;
|
|
1968
1971
|
}
|
|
1969
1972
|
}
|
|
1973
|
+
`;
|
|
1974
|
+
}
|
|
1975
|
+
function style() {
|
|
1976
|
+
return `@import "./.riebeckite/plugin-styles.css";
|
|
1977
|
+
@import "./.riebeckite/theme-styles.css";
|
|
1970
1978
|
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
return {
|
|
1975
|
-
"application/atom+xml": "xml",
|
|
1976
|
-
"application/json": "json",
|
|
1977
|
-
"application/rss+xml": "xml",
|
|
1978
|
-
"application/xml": "xml",
|
|
1979
|
-
"text/html": "html",
|
|
1980
|
-
"text/plain": "txt",
|
|
1981
|
-
"text/xml": "xml"
|
|
1982
|
-
};
|
|
1979
|
+
body {
|
|
1980
|
+
margin: 0;
|
|
1981
|
+
font-family: system-ui, sans-serif;
|
|
1983
1982
|
}
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
});
|
|
1983
|
+
|
|
1984
|
+
.site-header {
|
|
1985
|
+
display: flex;
|
|
1986
|
+
align-items: center;
|
|
1987
|
+
justify-content: space-between;
|
|
1988
|
+
gap: 1rem;
|
|
1989
|
+
padding: 1rem;
|
|
1990
|
+
border-bottom: 1px solid #d1d5db;
|
|
1993
1991
|
}
|
|
1994
1992
|
|
|
1995
|
-
|
|
1996
|
-
|
|
1993
|
+
.site-header__home {
|
|
1994
|
+
color: #111827;
|
|
1995
|
+
font-weight: 700;
|
|
1996
|
+
text-decoration: none;
|
|
1997
|
+
}
|
|
1997
1998
|
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
writeGeneratedFile(paths2.pluginStyles, createPluginStylesEntry(config));
|
|
2004
|
-
writeGeneratedFile(paths2.themeStyles, createThemeStylesEntry(config));
|
|
1999
|
+
.site-article {
|
|
2000
|
+
display: block;
|
|
2001
|
+
max-width: 48rem;
|
|
2002
|
+
padding: 2rem 1rem;
|
|
2003
|
+
margin: 0 auto;
|
|
2005
2004
|
}
|
|
2006
|
-
|
|
2007
|
-
return createStylesheetEntry(
|
|
2008
|
-
collectPluginStyleSpecifiers(config),
|
|
2009
|
-
"Plugin default styles, in resolved plugin order. Generated by @riebeckite/honox; do not edit. Import this before the theme stylesheet so a theme can override plugin defaults."
|
|
2010
|
-
);
|
|
2005
|
+
`;
|
|
2011
2006
|
}
|
|
2012
|
-
function
|
|
2013
|
-
return
|
|
2014
|
-
|
|
2015
|
-
|
|
2007
|
+
function siteHeader() {
|
|
2008
|
+
return `import { ColorModeToggle } from "@riebeckite/plugin-color-mode";
|
|
2009
|
+
import { config } from "../config";
|
|
2010
|
+
|
|
2011
|
+
export function SiteHeader() {
|
|
2012
|
+
return (
|
|
2013
|
+
<header class="site-header">
|
|
2014
|
+
<a href="/" class="site-header__home">
|
|
2015
|
+
{config.site.title}
|
|
2016
|
+
</a>
|
|
2017
|
+
<ColorModeToggle />
|
|
2018
|
+
</header>
|
|
2016
2019
|
);
|
|
2017
2020
|
}
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
+
`;
|
|
2022
|
+
}
|
|
2023
|
+
function article() {
|
|
2024
|
+
return `import type { PostContent } from "@riebeckite/core";
|
|
2025
|
+
import { Article, ArticleContent, ArticleLayout } from "@riebeckite/honox/ui";
|
|
2026
|
+
|
|
2027
|
+
export function SiteArticle({
|
|
2028
|
+
post,
|
|
2029
|
+
afterMeta,
|
|
2030
|
+
}: {
|
|
2031
|
+
post: PostContent;
|
|
2032
|
+
afterMeta?: string;
|
|
2033
|
+
}) {
|
|
2034
|
+
return (
|
|
2035
|
+
<Article class="site-article">
|
|
2036
|
+
<ArticleLayout>
|
|
2037
|
+
<ArticleContent>
|
|
2038
|
+
{afterMeta ? (
|
|
2039
|
+
<div
|
|
2040
|
+
class="site-article__after-meta"
|
|
2041
|
+
dangerouslySetInnerHTML={{ __html: afterMeta }}
|
|
2042
|
+
/>
|
|
2043
|
+
) : null}
|
|
2044
|
+
<div dangerouslySetInnerHTML={{ __html: post.html ?? "" }} />
|
|
2045
|
+
</ArticleContent>
|
|
2046
|
+
</ArticleLayout>
|
|
2047
|
+
</Article>
|
|
2021
2048
|
);
|
|
2022
2049
|
}
|
|
2023
|
-
function createStylesheetEntry(moduleSpecifiers, banner) {
|
|
2024
|
-
const imports = uniqueStrings(moduleSpecifiers).map((specifier) => `@import ${JSON.stringify(specifier)};`).join("\n");
|
|
2025
|
-
if (!banner) return imports;
|
|
2026
|
-
const header = `/* ${banner.replace(/\*\//g, "* /")} */`;
|
|
2027
|
-
return imports ? `${header}
|
|
2028
|
-
${imports}
|
|
2029
|
-
` : `${header}
|
|
2030
2050
|
`;
|
|
2031
2051
|
}
|
|
2032
|
-
function
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
}
|
|
2052
|
+
function renderer() {
|
|
2053
|
+
return `import type { PluginHeadTag } from "@riebeckite/core";
|
|
2054
|
+
import { jsxRenderer } from "hono/jsx-renderer";
|
|
2055
|
+
import { Link, Script } from "honox/server";
|
|
2056
|
+
import { ColorModeScript } from "@riebeckite/plugin-color-mode";
|
|
2057
|
+
import { SiteHeader } from "../components/site-header";
|
|
2058
|
+
import { config } from "../config";
|
|
2059
|
+
|
|
2060
|
+
function themeAttributes() {
|
|
2061
|
+
const { theme } = config;
|
|
2036
2062
|
|
|
2037
|
-
// src/client_module.ts
|
|
2038
|
-
import {
|
|
2039
|
-
serializePublicClientConfig
|
|
2040
|
-
} from "@riebeckite/core";
|
|
2041
|
-
var clientModuleId = "virtual:riebeckite/client";
|
|
2042
|
-
var resolvedClientModuleId = `\0${clientModuleId}`;
|
|
2043
|
-
function riebeckiteClientModule(getConfig) {
|
|
2044
2063
|
return {
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
load(id) {
|
|
2051
|
-
if (id !== resolvedClientModuleId) return null;
|
|
2052
|
-
return createClientModule(getConfig());
|
|
2053
|
-
}
|
|
2064
|
+
...theme.attributes,
|
|
2065
|
+
"data-theme": theme.colorMode === "system" ? undefined : theme.colorMode,
|
|
2066
|
+
"data-theme-name": theme.name,
|
|
2067
|
+
"data-typography": theme.typography,
|
|
2068
|
+
"data-article-layout": theme.articleLayout,
|
|
2054
2069
|
};
|
|
2055
2070
|
}
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
const
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2071
|
+
|
|
2072
|
+
export default jsxRenderer(({ children }, c) => {
|
|
2073
|
+
const headTags: readonly PluginHeadTag[] = c.get("headTags") ?? [];
|
|
2074
|
+
|
|
2075
|
+
return (
|
|
2076
|
+
<html
|
|
2077
|
+
lang={c.get("htmlLanguage") ?? config.site.locale}
|
|
2078
|
+
{...themeAttributes()}
|
|
2079
|
+
>
|
|
2080
|
+
<head>
|
|
2081
|
+
<meta charset="utf-8" />
|
|
2082
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
2083
|
+
<title>{config.site.title}</title>
|
|
2084
|
+
<ColorModeScript />
|
|
2085
|
+
<Link href="/app/style.css" rel="stylesheet" />
|
|
2086
|
+
{headTags.map(renderHeadTag)}
|
|
2087
|
+
<Script src="/app/client.ts" async />
|
|
2088
|
+
</head>
|
|
2089
|
+
<body class="riebeckite-page">
|
|
2090
|
+
<SiteHeader />
|
|
2091
|
+
{children}
|
|
2092
|
+
</body>
|
|
2093
|
+
</html>
|
|
2094
|
+
);
|
|
2095
|
+
});
|
|
2096
|
+
|
|
2097
|
+
function renderHeadTag(tag: PluginHeadTag, index: number) {
|
|
2098
|
+
const key = \`\${tag.tag}-\${index}\`;
|
|
2099
|
+
if (tag.tag === "meta") return <meta {...tag.attrs} key={key} />;
|
|
2100
|
+
if (tag.tag === "link") return <link {...tag.attrs} key={key} />;
|
|
2101
|
+
return (
|
|
2102
|
+
<script
|
|
2103
|
+
{...tag.attrs}
|
|
2104
|
+
key={key}
|
|
2105
|
+
dangerouslySetInnerHTML={
|
|
2106
|
+
tag.children ? { __html: tag.children } : undefined
|
|
2107
|
+
}
|
|
2108
|
+
/>
|
|
2109
|
+
);
|
|
2110
|
+
}
|
|
2111
|
+
`;
|
|
2112
|
+
}
|
|
2113
|
+
function indexRoute() {
|
|
2114
|
+
return `import { isPublished } from "@riebeckite/core";
|
|
2115
|
+
import { createRoute } from "honox/factory";
|
|
2116
|
+
import { SiteArticle } from "../components/article";
|
|
2117
|
+
import { config } from "../config";
|
|
2118
|
+
import { content } from "../content";
|
|
2119
|
+
|
|
2120
|
+
export default createRoute(async (c) => {
|
|
2121
|
+
const manifest = await content.getManifest();
|
|
2122
|
+
const indexEntry = manifest.bySlug.get("index");
|
|
2123
|
+
if (indexEntry && indexEntry.permalink !== "/") {
|
|
2124
|
+
return c.redirect(indexEntry.permalink, 308);
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
const post = await content.getProcessedContent("index");
|
|
2128
|
+
if (!isPublished(config, post.frontmatter)) {
|
|
2129
|
+
return c.notFound();
|
|
2130
|
+
}
|
|
2131
|
+
|
|
2132
|
+
if (indexEntry) {
|
|
2133
|
+
c.set("htmlLanguage", indexEntry.publicLocation.metadata?.["l10n.lang"]);
|
|
2134
|
+
c.set("headTags", indexEntry.headTags ?? []);
|
|
2069
2135
|
}
|
|
2070
|
-
return `${imports.join("\n")}
|
|
2071
2136
|
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
}
|
|
2137
|
+
return c.render(
|
|
2138
|
+
<SiteArticle
|
|
2139
|
+
post={post}
|
|
2140
|
+
afterMeta={indexEntry?.bodySlots?.["article.after-meta"]}
|
|
2141
|
+
/>,
|
|
2142
|
+
);
|
|
2143
|
+
});
|
|
2075
2144
|
`;
|
|
2076
2145
|
}
|
|
2146
|
+
function slugRoute() {
|
|
2147
|
+
return `import { isPublished } from "@riebeckite/core";
|
|
2148
|
+
import {
|
|
2149
|
+
contentRouteSsgParams,
|
|
2150
|
+
resolveContentRoute,
|
|
2151
|
+
} from "@riebeckite/honox/server";
|
|
2152
|
+
import { createRoute } from "honox/factory";
|
|
2153
|
+
import { SiteArticle } from "../components/article";
|
|
2154
|
+
import { config } from "../config";
|
|
2155
|
+
import { content } from "../content";
|
|
2077
2156
|
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2157
|
+
export default createRoute(
|
|
2158
|
+
contentRouteSsgParams("/:slug{.+}", async () => {
|
|
2159
|
+
const manifest = await content.getManifest();
|
|
2160
|
+
return manifest.entries
|
|
2161
|
+
.filter((entry) => isPublished(config, entry.frontmatter))
|
|
2162
|
+
.filter((entry) => entry.permalink !== "/")
|
|
2163
|
+
.map((entry) => ({ slug: entry.permalink.replace(/^\\/+/, "") }));
|
|
2164
|
+
}),
|
|
2165
|
+
async (c) => {
|
|
2166
|
+
const requestedSlug = c.req.param("slug");
|
|
2167
|
+
if (!requestedSlug) return c.notFound();
|
|
2168
|
+
if (/\\.[a-zA-Z0-9]+$/.test(requestedSlug)) return c.notFound();
|
|
2169
|
+
|
|
2170
|
+
const manifest = await content.getManifest();
|
|
2171
|
+
const route = resolveContentRoute(manifest, c.req.path);
|
|
2172
|
+
if (!route) return c.notFound();
|
|
2173
|
+
if (route.kind === "redirect")
|
|
2174
|
+
return c.redirect(route.location, route.status);
|
|
2175
|
+
|
|
2176
|
+
const post = await content.getProcessedContent(route.entry.slug);
|
|
2177
|
+
if (!isPublished(config, post.frontmatter)) {
|
|
2178
|
+
return c.notFound();
|
|
2179
|
+
}
|
|
2180
|
+
|
|
2181
|
+
c.set("htmlLanguage", route.entry.publicLocation.metadata?.["l10n.lang"]);
|
|
2182
|
+
c.set("headTags", route.entry.headTags ?? []);
|
|
2183
|
+
|
|
2184
|
+
return c.render(
|
|
2185
|
+
<SiteArticle
|
|
2186
|
+
post={post}
|
|
2187
|
+
afterMeta={route.entry.bodySlots?.["article.after-meta"]}
|
|
2188
|
+
/>,
|
|
2093
2189
|
);
|
|
2094
|
-
}
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
);
|
|
2190
|
+
},
|
|
2191
|
+
);
|
|
2192
|
+
`;
|
|
2098
2193
|
}
|
|
2099
|
-
|
|
2194
|
+
|
|
2195
|
+
// src/scaffold/index.ts
|
|
2196
|
+
var ScaffoldSiteError = class extends Error {
|
|
2100
2197
|
constructor(message) {
|
|
2101
2198
|
super(message);
|
|
2102
|
-
this.name = "
|
|
2199
|
+
this.name = "ScaffoldSiteError";
|
|
2103
2200
|
}
|
|
2104
2201
|
};
|
|
2105
|
-
async function
|
|
2106
|
-
const
|
|
2107
|
-
const
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2202
|
+
async function scaffoldRiebeckiteSite(options) {
|
|
2203
|
+
const targetDirectory = path7.resolve(options.targetDirectory);
|
|
2204
|
+
const files = siteTemplateFiles(templateVariables(options, targetDirectory));
|
|
2205
|
+
await assertTargetWritable(
|
|
2206
|
+
targetDirectory,
|
|
2207
|
+
files,
|
|
2208
|
+
options.overwrite ?? false
|
|
2209
|
+
);
|
|
2210
|
+
for (const file of files) {
|
|
2211
|
+
const filePath = path7.join(targetDirectory, file.path);
|
|
2212
|
+
await fs6.mkdir(path7.dirname(filePath), { recursive: true });
|
|
2213
|
+
await fs6.writeFile(filePath, file.content, "utf8");
|
|
2214
|
+
}
|
|
2215
|
+
return { targetDirectory, files: files.map((file) => file.path) };
|
|
2216
|
+
}
|
|
2217
|
+
function templateVariables(options, targetDirectory) {
|
|
2218
|
+
const name = normalizePackageName(
|
|
2219
|
+
options.name ?? path7.basename(targetDirectory)
|
|
2220
|
+
);
|
|
2115
2221
|
return {
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2222
|
+
name,
|
|
2223
|
+
title: options.siteTitle ?? name,
|
|
2224
|
+
description: options.description ?? "",
|
|
2225
|
+
baseUrl: options.baseUrl ?? "",
|
|
2226
|
+
locale: options.locale ?? "en"
|
|
2120
2227
|
};
|
|
2121
2228
|
}
|
|
2122
|
-
async function
|
|
2229
|
+
async function assertTargetWritable(targetDirectory, files, overwrite) {
|
|
2230
|
+
let entries;
|
|
2123
2231
|
try {
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2232
|
+
entries = await fs6.readdir(targetDirectory);
|
|
2233
|
+
} catch (error) {
|
|
2234
|
+
if (isNotFoundError(error)) return;
|
|
2235
|
+
throw error;
|
|
2128
2236
|
}
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
const server2 = await createServer2({ root: options.root });
|
|
2132
|
-
await server2.listen();
|
|
2133
|
-
server2.printUrls();
|
|
2134
|
-
await waitForShutdown(server2);
|
|
2135
|
-
}
|
|
2136
|
-
async function buildHonoxApplication(options) {
|
|
2137
|
-
await runTraced(
|
|
2138
|
-
options.tracer,
|
|
2139
|
-
"integration.honox.client_build",
|
|
2140
|
-
() => build({ root: options.root, mode: "client" })
|
|
2237
|
+
const conflicts = entries.filter(
|
|
2238
|
+
(entry) => files.some((file) => file.path.split("/")[0] === entry)
|
|
2141
2239
|
);
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2240
|
+
if (conflicts.length === 0) return;
|
|
2241
|
+
if (overwrite) return;
|
|
2242
|
+
throw new ScaffoldSiteError(
|
|
2243
|
+
`The target directory is not empty: ${targetDirectory}
|
|
2244
|
+
Existing entries: ${conflicts.slice(0, 5).join(", ")}
|
|
2245
|
+
Pass --force to overwrite generated files.`
|
|
2146
2246
|
);
|
|
2147
2247
|
}
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
async function waitForShutdown(server2) {
|
|
2152
|
-
await new Promise((resolve) => {
|
|
2153
|
-
const close = () => {
|
|
2154
|
-
void server2.close().finally(resolve);
|
|
2155
|
-
};
|
|
2156
|
-
process.once("SIGINT", close);
|
|
2157
|
-
process.once("SIGTERM", close);
|
|
2158
|
-
});
|
|
2159
|
-
}
|
|
2160
|
-
async function findViteApplicationRoots(root) {
|
|
2161
|
-
const directories = [root];
|
|
2162
|
-
const applicationRoots = [];
|
|
2163
|
-
while (directories.length > 0) {
|
|
2164
|
-
const directory = directories.pop();
|
|
2165
|
-
if (!directory) continue;
|
|
2166
|
-
if (await hasViteConfig(directory)) applicationRoots.push(directory);
|
|
2167
|
-
const entries = await fs6.readdir(directory, { withFileTypes: true });
|
|
2168
|
-
for (const entry of entries) {
|
|
2169
|
-
if (!entry.isDirectory() || entry.name === "node_modules" || entry.name === ".git" || entry.name === "tests") {
|
|
2170
|
-
continue;
|
|
2171
|
-
}
|
|
2172
|
-
directories.push(path6.join(directory, entry.name));
|
|
2173
|
-
}
|
|
2174
|
-
}
|
|
2175
|
-
return applicationRoots;
|
|
2176
|
-
}
|
|
2177
|
-
async function hasViteConfig(directory) {
|
|
2178
|
-
for (const fileName of viteConfigFileNames) {
|
|
2179
|
-
try {
|
|
2180
|
-
if ((await fs6.stat(path6.join(directory, fileName))).isFile()) return true;
|
|
2181
|
-
} catch {
|
|
2182
|
-
}
|
|
2183
|
-
}
|
|
2184
|
-
return false;
|
|
2185
|
-
}
|
|
2186
|
-
|
|
2187
|
-
// src/vite_plugin.ts
|
|
2188
|
-
var defaultSsrExternals = [
|
|
2189
|
-
"extend",
|
|
2190
|
-
"debug",
|
|
2191
|
-
"node:fs/promises",
|
|
2192
|
-
"node:path",
|
|
2193
|
-
"parse-numeric-range",
|
|
2194
|
-
"slugify",
|
|
2195
|
-
"vfile-matter",
|
|
2196
|
-
"yaml"
|
|
2197
|
-
];
|
|
2198
|
-
function riebeckite(options = {}) {
|
|
2199
|
-
let resolvedConfig;
|
|
2200
|
-
const getConfig = () => {
|
|
2201
|
-
if (!resolvedConfig) {
|
|
2202
|
-
throw new Error("Riebeckite config has not been loaded yet.");
|
|
2203
|
-
}
|
|
2204
|
-
return resolvedConfig;
|
|
2205
|
-
};
|
|
2206
|
-
return [
|
|
2207
|
-
{
|
|
2208
|
-
name: "riebeckite-host-integration",
|
|
2209
|
-
async config(userConfig) {
|
|
2210
|
-
const root = userConfig.root ? path7.resolve(userConfig.root) : process.cwd();
|
|
2211
|
-
const appRoot = options.appRoot ?? root;
|
|
2212
|
-
const application = await resolveHonoxApplication({
|
|
2213
|
-
configRoot: options.configRoot ?? appRoot,
|
|
2214
|
-
configFile: options.configFile,
|
|
2215
|
-
appRoot,
|
|
2216
|
-
workspaceRoot: options.workspaceRoot
|
|
2217
|
-
});
|
|
2218
|
-
resolvedConfig = application.config;
|
|
2219
|
-
writeRiebeckiteAssetEntries(resolvedConfig, {
|
|
2220
|
-
pluginStyles: path7.join(appRoot, "app/.riebeckite/plugin-styles.css"),
|
|
2221
|
-
themeStyles: path7.join(appRoot, "app/.riebeckite/theme-styles.css")
|
|
2222
|
-
});
|
|
2223
|
-
return {
|
|
2224
|
-
define: {
|
|
2225
|
-
"process.env.RIEBECKITE_APP_ROOT": JSON.stringify(appRoot)
|
|
2226
|
-
},
|
|
2227
|
-
resolve: {
|
|
2228
|
-
alias: options.workspaceRoot ? createWorkspacePackageAliases(options.workspaceRoot) : []
|
|
2229
|
-
}
|
|
2230
|
-
};
|
|
2231
|
-
}
|
|
2232
|
-
},
|
|
2233
|
-
riebeckiteClientModule(getConfig)
|
|
2234
|
-
];
|
|
2235
|
-
}
|
|
2236
|
-
function riebeckiteVite(options = {}) {
|
|
2237
|
-
const { ssg, ssrExternals, ...integration } = options;
|
|
2238
|
-
return [
|
|
2239
|
-
...riebeckite(integration),
|
|
2240
|
-
riebeckiteSsrExternals([...defaultSsrExternals, ...ssrExternals ?? []]),
|
|
2241
|
-
createRiebeckiteSsg(ssg)
|
|
2242
|
-
];
|
|
2248
|
+
function normalizePackageName(value) {
|
|
2249
|
+
const normalized = value.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[-_.]+/, "").replace(/[-_.]+$/, "");
|
|
2250
|
+
return normalized || "riebeckite-site";
|
|
2243
2251
|
}
|
|
2244
|
-
function
|
|
2245
|
-
return
|
|
2246
|
-
name: "riebeckite-ssr-externals",
|
|
2247
|
-
config() {
|
|
2248
|
-
return {
|
|
2249
|
-
environments: {
|
|
2250
|
-
ssr: {
|
|
2251
|
-
resolve: {
|
|
2252
|
-
external: [...externals]
|
|
2253
|
-
}
|
|
2254
|
-
}
|
|
2255
|
-
}
|
|
2256
|
-
};
|
|
2257
|
-
}
|
|
2258
|
-
};
|
|
2252
|
+
function isNotFoundError(error) {
|
|
2253
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
2259
2254
|
}
|
|
2260
2255
|
export {
|
|
2261
2256
|
ScaffoldSiteError,
|