@riebeckite/honox 0.0.8 → 0.0.9
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 +669 -668
- package/dist/src/scaffold/app-templates.d.ts +15 -0
- package/dist/src/scaffold/version.d.ts +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// src/config_loader.ts
|
|
2
2
|
import fs2 from "node:fs/promises";
|
|
3
|
-
import os from "node:os";
|
|
4
3
|
import path2 from "node:path";
|
|
5
4
|
import { build as buildWithEsbuild } from "esbuild";
|
|
6
5
|
|
|
@@ -112,7 +111,7 @@ function escapeRegExp(value) {
|
|
|
112
111
|
async function loadRiebeckiteConfig(options) {
|
|
113
112
|
const configFile = options.configFile ?? "riebeckite.config.ts";
|
|
114
113
|
const temporaryDirectory = await fs2.mkdtemp(
|
|
115
|
-
path2.join(
|
|
114
|
+
path2.join(options.configRoot, ".riebeckite-config-")
|
|
116
115
|
);
|
|
117
116
|
const outputFile = path2.join(temporaryDirectory, "config.mjs");
|
|
118
117
|
try {
|
|
@@ -1337,108 +1336,494 @@ function riebeckiteSsrExternals(externals) {
|
|
|
1337
1336
|
};
|
|
1338
1337
|
}
|
|
1339
1338
|
|
|
1340
|
-
// src/scaffold/
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1339
|
+
// src/scaffold/app-templates.ts
|
|
1340
|
+
function server() {
|
|
1341
|
+
return `import { mountRiebeckiteEndpoints } from "@riebeckite/honox/server";
|
|
1342
|
+
import { createApp } from "honox/server";
|
|
1343
|
+
import { config } from "./config";
|
|
1344
|
+
import { content } from "./content";
|
|
1345
|
+
|
|
1346
|
+
const app = createApp({
|
|
1347
|
+
init: (app) => {
|
|
1348
|
+
mountRiebeckiteEndpoints(app, { config, content });
|
|
1349
|
+
},
|
|
1350
|
+
});
|
|
1351
|
+
|
|
1352
|
+
export default app;
|
|
1353
|
+
export { config, content };
|
|
1354
|
+
`;
|
|
1355
|
+
}
|
|
1356
|
+
function client() {
|
|
1357
|
+
return `import { initRiebeckiteClient } from "virtual:riebeckite/client";
|
|
1358
|
+
import { createClient } from "honox/client";
|
|
1359
|
+
|
|
1360
|
+
createClient();
|
|
1361
|
+
|
|
1362
|
+
if (document.readyState === "loading") {
|
|
1363
|
+
document.addEventListener("DOMContentLoaded", initPage, { once: true });
|
|
1364
|
+
} else {
|
|
1365
|
+
initPage();
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
function initPage() {
|
|
1369
|
+
initRiebeckiteClient();
|
|
1370
|
+
}
|
|
1371
|
+
`;
|
|
1372
|
+
}
|
|
1373
|
+
function appConfig() {
|
|
1374
|
+
return `import path from "node:path";
|
|
1375
|
+
import { fileURLToPath } from "node:url";
|
|
1376
|
+
import { resolveConfigModule } from "@riebeckite/core";
|
|
1377
|
+
import * as rawConfigModule from "../riebeckite.config";
|
|
1378
|
+
|
|
1379
|
+
const appRoot =
|
|
1380
|
+
process.env.RIEBECKITE_APP_ROOT ??
|
|
1381
|
+
fileURLToPath(new URL("../", import.meta.url));
|
|
1382
|
+
const resolvedConfig = resolveConfigModule(rawConfigModule);
|
|
1383
|
+
|
|
1384
|
+
export const config = {
|
|
1385
|
+
...resolvedConfig,
|
|
1386
|
+
buildDirectory: path.join(appRoot, ".riebeckite"),
|
|
1387
|
+
content: {
|
|
1388
|
+
...resolvedConfig.content,
|
|
1389
|
+
directory: path.resolve(appRoot, resolvedConfig.content.directory),
|
|
1390
|
+
},
|
|
1344
1391
|
};
|
|
1345
|
-
|
|
1346
|
-
var THEMES_INDEX_URL = "https://github.com/Rerurate514/riebeckite/tree/main/packages/themes";
|
|
1347
|
-
function pluginReadmeUrl(slug) {
|
|
1348
|
-
return `https://github.com/Rerurate514/riebeckite/blob/main/packages/plugins/${slug}/README.md`;
|
|
1392
|
+
`;
|
|
1349
1393
|
}
|
|
1350
|
-
function
|
|
1351
|
-
return `
|
|
1394
|
+
function appContent() {
|
|
1395
|
+
return `import { ContentManager } from "@riebeckite/core";
|
|
1396
|
+
import { config } from "./config";
|
|
1397
|
+
import { CONTENT_DIR } from "./constants/paths";
|
|
1398
|
+
|
|
1399
|
+
export const content = new ContentManager(
|
|
1400
|
+
CONTENT_DIR,
|
|
1401
|
+
config.content.exclude,
|
|
1402
|
+
{
|
|
1403
|
+
config,
|
|
1404
|
+
plugins: config.plugins,
|
|
1405
|
+
},
|
|
1406
|
+
);
|
|
1407
|
+
`;
|
|
1352
1408
|
}
|
|
1353
|
-
function
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
}
|
|
1379
|
-
|
|
1380
|
-
for (const page of preset.contentPages) {
|
|
1381
|
-
if (page === "index") {
|
|
1382
|
-
pushLocalized("index", (language) => indexContent(variables, language));
|
|
1383
|
-
} else if (page === "framework/plugins") {
|
|
1384
|
-
pushLocalized(
|
|
1385
|
-
"framework/plugins",
|
|
1386
|
-
(language) => pluginsContent(language)
|
|
1387
|
-
);
|
|
1388
|
-
} else if (page === "framework/themes") {
|
|
1389
|
-
pushLocalized("framework/themes", (language) => themesContent(language));
|
|
1390
|
-
} else if (page === "guide") {
|
|
1391
|
-
pushEnglishOnly("guide", guideContent);
|
|
1392
|
-
} else if (page === "examples") {
|
|
1393
|
-
pushLocalized(
|
|
1394
|
-
"examples",
|
|
1395
|
-
(language) => examplesContent(preset, language)
|
|
1396
|
-
);
|
|
1397
|
-
} else if (page === "reference/plugins") {
|
|
1398
|
-
pushEnglishOnly(
|
|
1399
|
-
"reference/plugins",
|
|
1400
|
-
() => referencePluginsContent(preset, variables)
|
|
1401
|
-
);
|
|
1402
|
-
} else if (page === "reference/themes") {
|
|
1403
|
-
pushEnglishOnly("reference/themes", referenceThemesContent);
|
|
1404
|
-
}
|
|
1409
|
+
function paths() {
|
|
1410
|
+
return `import path from "node:path";
|
|
1411
|
+
import { fileURLToPath } from "node:url";
|
|
1412
|
+
import { config } from "../config";
|
|
1413
|
+
|
|
1414
|
+
const appRoot =
|
|
1415
|
+
process.env.RIEBECKITE_APP_ROOT ??
|
|
1416
|
+
fileURLToPath(new URL("../../", import.meta.url));
|
|
1417
|
+
|
|
1418
|
+
export const CONTENT_DIR = path.resolve(appRoot, config.content.directory);
|
|
1419
|
+
export const ASSETS_ROOT = "public/";
|
|
1420
|
+
`;
|
|
1421
|
+
}
|
|
1422
|
+
function globalDeclarations() {
|
|
1423
|
+
return `import type { PluginHeadTag } from "@riebeckite/core";
|
|
1424
|
+
|
|
1425
|
+
declare module "virtual:riebeckite/client" {
|
|
1426
|
+
export function initRiebeckiteClient(): void;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
declare module "hono" {
|
|
1430
|
+
interface Env {
|
|
1431
|
+
Variables: {
|
|
1432
|
+
headTags?: readonly PluginHeadTag[];
|
|
1433
|
+
htmlLanguage?: string;
|
|
1434
|
+
};
|
|
1435
|
+
Bindings: Record<string, never>;
|
|
1405
1436
|
}
|
|
1406
|
-
return files;
|
|
1407
1437
|
}
|
|
1408
|
-
|
|
1409
|
-
return text[language];
|
|
1438
|
+
`;
|
|
1410
1439
|
}
|
|
1411
|
-
function
|
|
1412
|
-
|
|
1440
|
+
function style(preset) {
|
|
1441
|
+
const imports = [];
|
|
1442
|
+
if (preset.plugins.length > 0) {
|
|
1443
|
+
imports.push('@import "./.riebeckite/plugin-styles.css";');
|
|
1444
|
+
}
|
|
1445
|
+
if (preset.theme) {
|
|
1446
|
+
imports.push('@import "./.riebeckite/theme-styles.css";');
|
|
1447
|
+
}
|
|
1448
|
+
const blocks = [
|
|
1449
|
+
"",
|
|
1450
|
+
"body {",
|
|
1451
|
+
" margin: 0;",
|
|
1452
|
+
" font-family: system-ui, sans-serif;",
|
|
1453
|
+
"}",
|
|
1454
|
+
""
|
|
1455
|
+
];
|
|
1456
|
+
if (preset.appFiles.includes("header")) {
|
|
1457
|
+
blocks.push(
|
|
1458
|
+
".site-header {",
|
|
1459
|
+
" display: flex;",
|
|
1460
|
+
" align-items: center;",
|
|
1461
|
+
" justify-content: space-between;",
|
|
1462
|
+
" gap: 1rem;",
|
|
1463
|
+
" padding: 1rem;",
|
|
1464
|
+
" border-bottom: 1px solid #d1d5db;",
|
|
1465
|
+
"}",
|
|
1466
|
+
"",
|
|
1467
|
+
".site-header__home {",
|
|
1468
|
+
" color: #111827;",
|
|
1469
|
+
" font-weight: 700;",
|
|
1470
|
+
" text-decoration: none;",
|
|
1471
|
+
"}",
|
|
1472
|
+
""
|
|
1473
|
+
);
|
|
1474
|
+
}
|
|
1475
|
+
if (preset.appFiles.includes("article")) {
|
|
1476
|
+
blocks.push(
|
|
1477
|
+
".site-article {",
|
|
1478
|
+
" display: block;",
|
|
1479
|
+
" max-width: 48rem;",
|
|
1480
|
+
" padding: 2rem 1rem;",
|
|
1481
|
+
" margin: 0 auto;",
|
|
1482
|
+
"}",
|
|
1483
|
+
""
|
|
1484
|
+
);
|
|
1485
|
+
}
|
|
1486
|
+
if (!preset.theme) {
|
|
1487
|
+
blocks.push(
|
|
1488
|
+
".riebeckite-empty {",
|
|
1489
|
+
" max-width: 48rem;",
|
|
1490
|
+
" padding: 4rem 1rem;",
|
|
1491
|
+
" margin: 0 auto;",
|
|
1492
|
+
"}",
|
|
1493
|
+
""
|
|
1494
|
+
);
|
|
1495
|
+
}
|
|
1496
|
+
return [...imports, ...blocks].join("\n");
|
|
1413
1497
|
}
|
|
1414
|
-
function
|
|
1415
|
-
return
|
|
1498
|
+
function siteHeader() {
|
|
1499
|
+
return `import { ColorModeToggle } from "@riebeckite/plugin-color-mode";
|
|
1500
|
+
import { config } from "../config";
|
|
1501
|
+
|
|
1502
|
+
export function SiteHeader() {
|
|
1503
|
+
return (
|
|
1504
|
+
<header class="site-header">
|
|
1505
|
+
<a href="/" class="site-header__home">
|
|
1506
|
+
{config.site.title}
|
|
1507
|
+
</a>
|
|
1508
|
+
<ColorModeToggle />
|
|
1509
|
+
</header>
|
|
1510
|
+
);
|
|
1416
1511
|
}
|
|
1417
|
-
function codeBlock(language, code) {
|
|
1418
|
-
return `\`\`\`${language}
|
|
1419
|
-
${code}
|
|
1420
|
-
\`\`\`
|
|
1421
1512
|
`;
|
|
1422
1513
|
}
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1514
|
+
function article() {
|
|
1515
|
+
return `import type { PostContent } from "@riebeckite/core";
|
|
1516
|
+
import { Article, ArticleContent, ArticleLayout } from "@riebeckite/honox/ui";
|
|
1517
|
+
|
|
1518
|
+
export function SiteArticle({
|
|
1519
|
+
post,
|
|
1520
|
+
afterMeta,
|
|
1521
|
+
}: {
|
|
1522
|
+
post: PostContent;
|
|
1523
|
+
afterMeta?: string;
|
|
1524
|
+
}) {
|
|
1525
|
+
return (
|
|
1526
|
+
<Article class="site-article">
|
|
1527
|
+
<ArticleLayout>
|
|
1528
|
+
<ArticleContent>
|
|
1529
|
+
{afterMeta ? (
|
|
1530
|
+
<div
|
|
1531
|
+
class="site-article__after-meta"
|
|
1532
|
+
dangerouslySetInnerHTML={{ __html: afterMeta }}
|
|
1533
|
+
/>
|
|
1534
|
+
) : null}
|
|
1535
|
+
<div dangerouslySetInnerHTML={{ __html: post.html ?? "" }} />
|
|
1536
|
+
</ArticleContent>
|
|
1537
|
+
</ArticleLayout>
|
|
1538
|
+
</Article>
|
|
1539
|
+
);
|
|
1540
|
+
}
|
|
1541
|
+
`;
|
|
1542
|
+
}
|
|
1543
|
+
function renderer(preset) {
|
|
1544
|
+
if (!preset.theme) return bareRenderer();
|
|
1545
|
+
const hasHeader = preset.appFiles.includes("header");
|
|
1546
|
+
const hasColorMode = preset.plugins.some(
|
|
1547
|
+
(plugin) => plugin.package === "@riebeckite/plugin-color-mode"
|
|
1548
|
+
);
|
|
1549
|
+
return `import type { PluginHeadTag } from "@riebeckite/core";
|
|
1550
|
+
import { jsxRenderer } from "hono/jsx-renderer";
|
|
1551
|
+
import { Link, Script } from "honox/server";
|
|
1552
|
+
${hasColorMode ? `import { ColorModeScript } from "@riebeckite/plugin-color-mode";
|
|
1553
|
+
` : ""}${hasHeader ? `import { SiteHeader } from "../components/site-header";
|
|
1554
|
+
` : ""}import { config } from "../config";
|
|
1555
|
+
|
|
1556
|
+
function themeAttributes() {
|
|
1557
|
+
const { theme } = config;
|
|
1558
|
+
|
|
1559
|
+
return {
|
|
1560
|
+
...theme.attributes,
|
|
1561
|
+
"data-theme": theme.colorMode === "system" ? undefined : theme.colorMode,
|
|
1562
|
+
"data-theme-name": theme.name,
|
|
1563
|
+
"data-typography": theme.typography,
|
|
1564
|
+
"data-article-layout": theme.articleLayout,
|
|
1565
|
+
};
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
export default jsxRenderer(({ children }, c) => {
|
|
1569
|
+
const headTags: readonly PluginHeadTag[] = c.get("headTags") ?? [];
|
|
1570
|
+
|
|
1571
|
+
return (
|
|
1572
|
+
<html
|
|
1573
|
+
lang={c.get("htmlLanguage") ?? config.site.locale}
|
|
1574
|
+
{...themeAttributes()}
|
|
1575
|
+
>
|
|
1576
|
+
<head>
|
|
1577
|
+
<meta charset="utf-8" />
|
|
1578
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
1579
|
+
<title>{config.site.title}</title>
|
|
1580
|
+
${hasColorMode ? ` <ColorModeScript />
|
|
1581
|
+
` : ""} <Link href="/app/style.css" rel="stylesheet" />
|
|
1582
|
+
{headTags.map(renderHeadTag)}
|
|
1583
|
+
<Script src="/app/client.ts" async />
|
|
1584
|
+
</head>
|
|
1585
|
+
<body class="riebeckite-page">
|
|
1586
|
+
${hasHeader ? ` <SiteHeader />
|
|
1587
|
+
` : ""} {children}
|
|
1588
|
+
</body>
|
|
1589
|
+
</html>
|
|
1590
|
+
);
|
|
1591
|
+
});
|
|
1592
|
+
|
|
1593
|
+
function renderHeadTag(tag: PluginHeadTag, index: number) {
|
|
1594
|
+
const key = \`\${tag.tag}-\${index}\`;
|
|
1595
|
+
if (tag.tag === "meta") return <meta {...tag.attrs} key={key} />;
|
|
1596
|
+
if (tag.tag === "link") return <link {...tag.attrs} key={key} />;
|
|
1597
|
+
return (
|
|
1598
|
+
<script
|
|
1599
|
+
{...tag.attrs}
|
|
1600
|
+
key={key}
|
|
1601
|
+
dangerouslySetInnerHTML={
|
|
1602
|
+
tag.children ? { __html: tag.children } : undefined
|
|
1603
|
+
}
|
|
1604
|
+
/>
|
|
1605
|
+
);
|
|
1606
|
+
}
|
|
1607
|
+
`;
|
|
1608
|
+
}
|
|
1609
|
+
function bareRenderer() {
|
|
1610
|
+
return `import { jsxRenderer } from "hono/jsx-renderer";
|
|
1611
|
+
import { Link, Script } from "honox/server";
|
|
1612
|
+
import { config } from "../config";
|
|
1613
|
+
|
|
1614
|
+
export default jsxRenderer(({ children }, c) => (
|
|
1615
|
+
<html lang={c.get("htmlLanguage") ?? config.site.locale}>
|
|
1616
|
+
<head>
|
|
1617
|
+
<meta charset="utf-8" />
|
|
1618
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
1619
|
+
<title>{config.site.title}</title>
|
|
1620
|
+
<Link href="/app/style.css" rel="stylesheet" />
|
|
1621
|
+
<Script src="/app/client.ts" async />
|
|
1622
|
+
</head>
|
|
1623
|
+
<body class="riebeckite-page">{children}</body>
|
|
1624
|
+
</html>
|
|
1625
|
+
));
|
|
1626
|
+
`;
|
|
1627
|
+
}
|
|
1628
|
+
function indexRoute(preset) {
|
|
1629
|
+
if (!preset.appFiles.includes("article")) return staticIndexRoute();
|
|
1630
|
+
return `import { isPublished } from "@riebeckite/core";
|
|
1631
|
+
import { createRoute } from "honox/factory";
|
|
1632
|
+
import { SiteArticle } from "../components/article";
|
|
1633
|
+
import { config } from "../config";
|
|
1634
|
+
import { content } from "../content";
|
|
1635
|
+
|
|
1636
|
+
export default createRoute(async (c) => {
|
|
1637
|
+
const manifest = await content.getManifest();
|
|
1638
|
+
const indexEntry = manifest.bySlug.get("index");
|
|
1639
|
+
if (indexEntry && indexEntry.permalink !== "/") {
|
|
1640
|
+
return c.redirect(indexEntry.permalink, 308);
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
const post = await content.getProcessedContent("index");
|
|
1644
|
+
if (!isPublished(config, post.frontmatter)) {
|
|
1645
|
+
return c.notFound();
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
if (indexEntry) {
|
|
1649
|
+
c.set("htmlLanguage", indexEntry.publicLocation.metadata?.["l10n.lang"]);
|
|
1650
|
+
c.set("headTags", indexEntry.headTags ?? []);
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
return c.render(
|
|
1654
|
+
<SiteArticle
|
|
1655
|
+
post={post}
|
|
1656
|
+
afterMeta={indexEntry?.bodySlots?.["article.after-meta"]}
|
|
1657
|
+
/>,
|
|
1658
|
+
);
|
|
1659
|
+
});
|
|
1660
|
+
`;
|
|
1661
|
+
}
|
|
1662
|
+
function staticIndexRoute() {
|
|
1663
|
+
return `import { createRoute } from "honox/factory";
|
|
1664
|
+
import { config } from "../config";
|
|
1665
|
+
|
|
1666
|
+
export default createRoute((c) =>
|
|
1667
|
+
c.render(
|
|
1668
|
+
<main class="riebeckite-empty">
|
|
1669
|
+
<h1>{config.site.title}</h1>
|
|
1670
|
+
<p>This is a blank Riebeckite site. Add Markdown files under content/ to get started.</p>
|
|
1671
|
+
</main>,
|
|
1672
|
+
),
|
|
1673
|
+
);
|
|
1674
|
+
`;
|
|
1675
|
+
}
|
|
1676
|
+
function slugRoute() {
|
|
1677
|
+
return `import { isPublished } from "@riebeckite/core";
|
|
1678
|
+
import {
|
|
1679
|
+
contentRouteSsgParams,
|
|
1680
|
+
resolveContentRoute,
|
|
1681
|
+
} from "@riebeckite/honox/server";
|
|
1682
|
+
import { createRoute } from "honox/factory";
|
|
1683
|
+
import { SiteArticle } from "../components/article";
|
|
1684
|
+
import { config } from "../config";
|
|
1685
|
+
import { content } from "../content";
|
|
1686
|
+
|
|
1687
|
+
export default createRoute(
|
|
1688
|
+
contentRouteSsgParams("/:slug{.+}", async () => {
|
|
1689
|
+
const manifest = await content.getManifest();
|
|
1690
|
+
return manifest.entries
|
|
1691
|
+
.filter((entry) => isPublished(config, entry.frontmatter))
|
|
1692
|
+
.filter((entry) => entry.permalink !== "/")
|
|
1693
|
+
.map((entry) => ({ slug: entry.permalink.replace(/^\\/+/, "") }));
|
|
1694
|
+
}),
|
|
1695
|
+
async (c) => {
|
|
1696
|
+
const requestedSlug = c.req.param("slug");
|
|
1697
|
+
if (!requestedSlug) return c.notFound();
|
|
1698
|
+
if (/\\.[a-zA-Z0-9]+$/.test(requestedSlug)) return c.notFound();
|
|
1699
|
+
|
|
1700
|
+
const manifest = await content.getManifest();
|
|
1701
|
+
const route = resolveContentRoute(manifest, c.req.path);
|
|
1702
|
+
if (!route) return c.notFound();
|
|
1703
|
+
if (route.kind === "redirect")
|
|
1704
|
+
return c.redirect(route.location, route.status);
|
|
1705
|
+
|
|
1706
|
+
const post = await content.getProcessedContent(route.entry.slug);
|
|
1707
|
+
if (!isPublished(config, post.frontmatter)) {
|
|
1708
|
+
return c.notFound();
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
c.set("htmlLanguage", route.entry.publicLocation.metadata?.["l10n.lang"]);
|
|
1712
|
+
c.set("headTags", route.entry.headTags ?? []);
|
|
1713
|
+
|
|
1714
|
+
return c.render(
|
|
1715
|
+
<SiteArticle
|
|
1716
|
+
post={post}
|
|
1717
|
+
afterMeta={route.entry.bodySlots?.["article.after-meta"]}
|
|
1718
|
+
/>,
|
|
1719
|
+
);
|
|
1720
|
+
},
|
|
1721
|
+
);
|
|
1722
|
+
`;
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
// src/scaffold/localized-content.ts
|
|
1726
|
+
var HELPERS = {
|
|
1727
|
+
en: "https://github.com/Rerurate514/riebeckite/blob/main/docs/en/README.md",
|
|
1728
|
+
ja: "https://github.com/Rerurate514/riebeckite/blob/main/docs/ja/README.md"
|
|
1729
|
+
};
|
|
1730
|
+
var PLUGIN_INDEX_URL = "https://github.com/Rerurate514/riebeckite/tree/main/packages/plugins";
|
|
1731
|
+
var THEMES_INDEX_URL = "https://github.com/Rerurate514/riebeckite/tree/main/packages/themes";
|
|
1732
|
+
function pluginReadmeUrl(slug) {
|
|
1733
|
+
return `https://github.com/Rerurate514/riebeckite/blob/main/packages/plugins/${slug}/README.md`;
|
|
1734
|
+
}
|
|
1735
|
+
function themeReadmeUrl(slug) {
|
|
1736
|
+
return `https://github.com/Rerurate514/riebeckite/blob/main/packages/themes/${slug}/README.md`;
|
|
1737
|
+
}
|
|
1738
|
+
function localizedContentFiles(variables, preset) {
|
|
1739
|
+
const defaultLang = defaultLanguageForLocale(variables.locale);
|
|
1740
|
+
const files = [];
|
|
1741
|
+
const localized = preset.languages.length > 1;
|
|
1742
|
+
const pushLocalized = (basePath, build2) => {
|
|
1743
|
+
if (!localized) {
|
|
1744
|
+
files.push({
|
|
1745
|
+
path: `content/${basePath}.md`,
|
|
1746
|
+
content: build2(defaultLang)
|
|
1747
|
+
});
|
|
1748
|
+
return;
|
|
1749
|
+
}
|
|
1750
|
+
for (const language of SCAFFOLD_LANGUAGES) {
|
|
1751
|
+
const suffix = language === defaultLang ? "" : `.${language}`;
|
|
1752
|
+
files.push({
|
|
1753
|
+
path: `content/${basePath}${suffix}.md`,
|
|
1754
|
+
content: build2(language)
|
|
1755
|
+
});
|
|
1756
|
+
}
|
|
1757
|
+
};
|
|
1758
|
+
const pushEnglishOnly = (basePath, build2) => {
|
|
1759
|
+
const suffix = defaultLang === "en" ? "" : ".en";
|
|
1760
|
+
files.push({
|
|
1761
|
+
path: `content/${basePath}${suffix}.md`,
|
|
1762
|
+
content: build2()
|
|
1763
|
+
});
|
|
1764
|
+
};
|
|
1765
|
+
for (const page of preset.contentPages) {
|
|
1766
|
+
if (page === "index") {
|
|
1767
|
+
pushLocalized("index", (language) => indexContent(variables, language));
|
|
1768
|
+
} else if (page === "framework/plugins") {
|
|
1769
|
+
pushLocalized(
|
|
1770
|
+
"framework/plugins",
|
|
1771
|
+
(language) => pluginsContent(language)
|
|
1772
|
+
);
|
|
1773
|
+
} else if (page === "framework/themes") {
|
|
1774
|
+
pushLocalized("framework/themes", (language) => themesContent(language));
|
|
1775
|
+
} else if (page === "guide") {
|
|
1776
|
+
pushEnglishOnly("guide", guideContent);
|
|
1777
|
+
} else if (page === "examples") {
|
|
1778
|
+
pushLocalized(
|
|
1779
|
+
"examples",
|
|
1780
|
+
(language) => examplesContent(preset, language)
|
|
1781
|
+
);
|
|
1782
|
+
} else if (page === "reference/plugins") {
|
|
1783
|
+
pushEnglishOnly(
|
|
1784
|
+
"reference/plugins",
|
|
1785
|
+
() => referencePluginsContent(preset, variables)
|
|
1786
|
+
);
|
|
1787
|
+
} else if (page === "reference/themes") {
|
|
1788
|
+
pushEnglishOnly("reference/themes", referenceThemesContent);
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
return files;
|
|
1792
|
+
}
|
|
1793
|
+
function read(text, language) {
|
|
1794
|
+
return text[language];
|
|
1795
|
+
}
|
|
1796
|
+
function frontmatter() {
|
|
1797
|
+
return ["---", "publish: true", "---", ""].join("\n");
|
|
1798
|
+
}
|
|
1799
|
+
function heading(level, text) {
|
|
1800
|
+
return `${"#".repeat(level)} ${text}`;
|
|
1801
|
+
}
|
|
1802
|
+
function codeBlock(language, code) {
|
|
1803
|
+
return `\`\`\`${language}
|
|
1804
|
+
${code}
|
|
1805
|
+
\`\`\`
|
|
1806
|
+
`;
|
|
1807
|
+
}
|
|
1808
|
+
var INDEX = {
|
|
1809
|
+
lead: {
|
|
1810
|
+
en: "Welcome to your Riebeckite site.",
|
|
1811
|
+
ja: "あなたの Riebeckite サイトへようこそ。",
|
|
1812
|
+
"zh-CN": "欢迎来到你的 Riebeckite 站点。",
|
|
1813
|
+
es: "Bienvenido a tu sitio Riebeckite.",
|
|
1814
|
+
de: "Willkommen auf deiner Riebeckite-Seite.",
|
|
1815
|
+
fr: "Bienvenue sur votre site Riebeckite.",
|
|
1816
|
+
ko: "Riebeckite 사이트에 오신 것을 환영합니다."
|
|
1817
|
+
},
|
|
1818
|
+
translatedNote: {
|
|
1819
|
+
en: "Every page of this starter is available in seven languages. Switch with the selector below the page title.",
|
|
1820
|
+
ja: "このスターターのすべてのページは 7 言語で利用できます。ページタイトル下のセレクターで切り替えられます。",
|
|
1821
|
+
"zh-CN": "本模板的每个页面均提供七种语言版本,可用页面标题下方的选择器切换。",
|
|
1822
|
+
es: "Cada página de este starter está disponible en siete idiomas. Cámbialos con el selector bajo el título.",
|
|
1823
|
+
de: "Jede Seite dieses Starters ist in sieben Sprachen verfügbar. Wechsel mit dem Auswahlfeld unter dem Seitentitel.",
|
|
1824
|
+
fr: "Chaque page de ce starter est disponible en sept langues. Changez avec le sélecteur sous le titre.",
|
|
1825
|
+
ko: "이 스타터의 모든 페이지는 7개 언어로 제공됩니다. 페이지 제목 아래 선택기로 전환하세요."
|
|
1826
|
+
},
|
|
1442
1827
|
whatHeading: {
|
|
1443
1828
|
en: "What is Riebeckite?",
|
|
1444
1829
|
ja: "Riebeckite とは",
|
|
@@ -2424,7 +2809,7 @@ function referenceThemesContent() {
|
|
|
2424
2809
|
}
|
|
2425
2810
|
|
|
2426
2811
|
// src/scaffold/version.ts
|
|
2427
|
-
var RIEBECKITE_VERSION = "^0.0.
|
|
2812
|
+
var RIEBECKITE_VERSION = "^0.0.9";
|
|
2428
2813
|
|
|
2429
2814
|
// src/scaffold/templates.ts
|
|
2430
2815
|
function siteTemplateFiles(preset, variables) {
|
|
@@ -3104,589 +3489,205 @@ var README_DEMOS = {
|
|
|
3104
3489
|
" - title: Default",
|
|
3105
3490
|
" description: A clean, typographic theme.",
|
|
3106
3491
|
" meta: v0.0.5",
|
|
3107
|
-
" href: https://example.com/themes/default/",
|
|
3108
|
-
" - title: Minimal",
|
|
3109
|
-
" description: Stripped back to the essentials.",
|
|
3110
|
-
" meta: v0.0.5",
|
|
3111
|
-
" href: https://example.com/themes/minimal/",
|
|
3112
|
-
" - title: Gruvbox",
|
|
3113
|
-
" description: A warm, high-contrast palette.",
|
|
3114
|
-
" meta: v0.0.5",
|
|
3115
|
-
" href: https://example.com/themes/gruvbox/"
|
|
3116
|
-
].join("\n")
|
|
3117
|
-
)
|
|
3118
|
-
},
|
|
3119
|
-
"@riebeckite/plugin-dataview": {
|
|
3120
|
-
title: { en: "Dataview", ja: "Dataview" },
|
|
3121
|
-
intro: {
|
|
3122
|
-
en: "A `dataview` query renders a table of notes from the manifest.",
|
|
3123
|
-
ja: "`dataview` クエリがマニフェストからノート一覧を描画します。"
|
|
3124
|
-
},
|
|
3125
|
-
markdown: fence(
|
|
3126
|
-
"dataview",
|
|
3127
|
-
[
|
|
3128
|
-
'TABLE file.name AS "Name", status',
|
|
3129
|
-
"FROM #project",
|
|
3130
|
-
'WHERE status = "active"',
|
|
3131
|
-
"SORT file.name asc",
|
|
3132
|
-
"LIMIT 10"
|
|
3133
|
-
].join("\n")
|
|
3134
|
-
)
|
|
3135
|
-
},
|
|
3136
|
-
"@riebeckite/plugin-query": {
|
|
3137
|
-
title: { en: "Query", ja: "Query" },
|
|
3138
|
-
intro: {
|
|
3139
|
-
en: "A `query` fence is YAML that filters and sorts entries from the manifest.",
|
|
3140
|
-
ja: "`query` フェンスの YAML でマニフェストのエントリを絞り込み・並べ替えできます。"
|
|
3141
|
-
},
|
|
3142
|
-
markdown: fence(
|
|
3143
|
-
"query",
|
|
3144
|
-
[
|
|
3145
|
-
"filter:",
|
|
3146
|
-
" tags:",
|
|
3147
|
-
" any: [diary]",
|
|
3148
|
-
"sort:",
|
|
3149
|
-
" field: date",
|
|
3150
|
-
" order: desc",
|
|
3151
|
-
"limit: 5"
|
|
3152
|
-
].join("\n")
|
|
3153
|
-
)
|
|
3154
|
-
},
|
|
3155
|
-
"@riebeckite/plugin-bases": {
|
|
3156
|
-
title: { en: "Base views", ja: "Base ビュー" },
|
|
3157
|
-
intro: {
|
|
3158
|
-
en: "A `base` YAML fence renders a Base table view.",
|
|
3159
|
-
ja: "`base` YAML フェンスが Base のテーブルビューを描画します。"
|
|
3160
|
-
},
|
|
3161
|
-
markdown: fence(
|
|
3162
|
-
"base",
|
|
3163
|
-
[
|
|
3164
|
-
"filters:",
|
|
3165
|
-
" and:",
|
|
3166
|
-
' - file.hasTag("featured")',
|
|
3167
|
-
"properties:",
|
|
3168
|
-
" file.name:",
|
|
3169
|
-
" displayName: Title",
|
|
3170
|
-
"views:",
|
|
3171
|
-
" - type: table",
|
|
3172
|
-
" name: Featured",
|
|
3173
|
-
" limit: 10"
|
|
3174
|
-
].join("\n")
|
|
3175
|
-
)
|
|
3176
|
-
},
|
|
3177
|
-
"@riebeckite/plugin-kanban": {
|
|
3178
|
-
title: { en: "Kanban boards", ja: "カンバンボード" },
|
|
3179
|
-
intro: {
|
|
3180
|
-
en: "A note whose body is `##` columns of task lists becomes a board; `#tags` and `[[wikilinks]]` work inside cards.",
|
|
3181
|
-
ja: "本文が `##` 列とタスクリストでできたノートはボードになります。カード内では `#タグ` や `[[ウィキリンク]]` も使えます。"
|
|
3182
|
-
},
|
|
3183
|
-
markdown: fence(
|
|
3184
|
-
"md",
|
|
3185
|
-
[
|
|
3186
|
-
"## Backlog",
|
|
3187
|
-
"",
|
|
3188
|
-
"- [ ] Draft the release notes",
|
|
3189
|
-
"- [ ] Link to [[index]]",
|
|
3190
|
-
"",
|
|
3191
|
-
"## Done",
|
|
3192
|
-
"",
|
|
3193
|
-
"- [x] Publish the fixture"
|
|
3194
|
-
].join("\n")
|
|
3195
|
-
)
|
|
3196
|
-
}
|
|
3197
|
-
};
|
|
3198
|
-
var README_PAGE_LINKS = {
|
|
3199
|
-
"framework/plugins": { en: "Plugin tour", ja: "プラグインツアー" },
|
|
3200
|
-
"framework/themes": { en: "Theme tour", ja: "テーマツアー" },
|
|
3201
|
-
guide: { en: "Getting-started guide", ja: "はじめにガイド" },
|
|
3202
|
-
examples: { en: "Examples", ja: "サンプル集" },
|
|
3203
|
-
"reference/plugins": { en: "Plugin reference", ja: "プラグインリファレンス" },
|
|
3204
|
-
"reference/themes": { en: "Theme reference", ja: "テーマリファレンス" }
|
|
3205
|
-
};
|
|
3206
|
-
var ENGLISH_ONLY_PAGES = /* @__PURE__ */ new Set([
|
|
3207
|
-
"guide",
|
|
3208
|
-
"reference/plugins",
|
|
3209
|
-
"reference/themes"
|
|
3210
|
-
]);
|
|
3211
|
-
function fence(language, body) {
|
|
3212
|
-
const tick = "```";
|
|
3213
|
-
return `${tick}${language}
|
|
3214
|
-
${body}
|
|
3215
|
-
${tick}`;
|
|
3216
|
-
}
|
|
3217
|
-
function hasPlugin(preset, packageName) {
|
|
3218
|
-
return preset.plugins.some((plugin) => plugin.package === packageName);
|
|
3219
|
-
}
|
|
3220
|
-
function demoPackage(key) {
|
|
3221
|
-
return key.split("/", 2).join("/");
|
|
3222
|
-
}
|
|
3223
|
-
function readmePluginOptions(variables, preset, plugin) {
|
|
3224
|
-
return renderOptions(plugin.options, optionContext(preset, variables));
|
|
3225
|
-
}
|
|
3226
|
-
function configurationReferenceLines(preset, variables, words) {
|
|
3227
|
-
const lines = [
|
|
3228
|
-
`## ${words.configReference}`,
|
|
3229
|
-
"",
|
|
3230
|
-
words.configReferenceBody,
|
|
3231
|
-
""
|
|
3232
|
-
];
|
|
3233
|
-
if (preset.theme) {
|
|
3234
|
-
const themeCall = preset.theme.options ? `${preset.theme.factory}(${preset.theme.options})` : `${preset.theme.factory}()`;
|
|
3235
|
-
lines.push(`- **${words.theme}**: \`${themeCall}\``, "");
|
|
3236
|
-
}
|
|
3237
|
-
lines.push(
|
|
3238
|
-
`| Package | ${words.factory} | ${words.options} |`,
|
|
3239
|
-
"| --- | --- | --- |"
|
|
3240
|
-
);
|
|
3241
|
-
for (const plugin of preset.plugins) {
|
|
3242
|
-
const options = readmePluginOptions(variables, preset, plugin);
|
|
3243
|
-
const cell = options === null ? words.emDash : `\`${options}\``;
|
|
3244
|
-
lines.push(`| \`${plugin.package}\` | \`${plugin.factory}\` | ${cell} |`);
|
|
3245
|
-
}
|
|
3246
|
-
lines.push("");
|
|
3247
|
-
return lines;
|
|
3248
|
-
}
|
|
3249
|
-
function demoPagesLines(preset, variables, words, language) {
|
|
3250
|
-
const lines = [
|
|
3251
|
-
`## ${words.demoPages}`,
|
|
3252
|
-
"",
|
|
3253
|
-
words.demoPagesBody,
|
|
3254
|
-
""
|
|
3255
|
-
];
|
|
3256
|
-
const defaultLang = defaultLanguageForLocale(variables.locale);
|
|
3257
|
-
const pages = preset.contentPages.filter((page) => page !== "index");
|
|
3258
|
-
for (const page of pages) {
|
|
3259
|
-
const label = README_PAGE_LINKS[page]?.[language] ?? `/${page}/`;
|
|
3260
|
-
const suffix = ENGLISH_ONLY_PAGES.has(page) && defaultLang !== "en" ? ".en" : "";
|
|
3261
|
-
const source = `content/${page}${suffix}.md`;
|
|
3262
|
-
const url = `/${page}/`;
|
|
3263
|
-
lines.push(`- [**${label}**](${source}) — live at [\`${url}\`](${url})`);
|
|
3264
|
-
}
|
|
3265
|
-
lines.push("");
|
|
3266
|
-
return lines;
|
|
3267
|
-
}
|
|
3268
|
-
var README_DEMO_ORDER = [
|
|
3269
|
-
"@riebeckite/plugin-obsidian-markdown/callout",
|
|
3270
|
-
"@riebeckite/plugin-obsidian-markdown/wikilinks",
|
|
3271
|
-
"@riebeckite/plugin-code-enhance",
|
|
3272
|
-
"@riebeckite/plugin-code-tabs",
|
|
3273
|
-
"@riebeckite/plugin-mermaid",
|
|
3274
|
-
"@riebeckite/plugin-d2",
|
|
3275
|
-
"@riebeckite/plugin-graphviz",
|
|
3276
|
-
"@riebeckite/plugin-chartjs",
|
|
3277
|
-
"@riebeckite/plugin-vega-lite",
|
|
3278
|
-
"@riebeckite/plugin-wavedrom",
|
|
3279
|
-
"@riebeckite/plugin-markmap",
|
|
3280
|
-
"@riebeckite/plugin-map",
|
|
3281
|
-
"@riebeckite/plugin-marp",
|
|
3282
|
-
"@riebeckite/plugin-qr-code",
|
|
3283
|
-
"@riebeckite/plugin-rich-embed",
|
|
3284
|
-
"@riebeckite/plugin-gallery",
|
|
3285
|
-
"@riebeckite/plugin-dataview",
|
|
3286
|
-
"@riebeckite/plugin-query",
|
|
3287
|
-
"@riebeckite/plugin-bases",
|
|
3288
|
-
"@riebeckite/plugin-kanban"
|
|
3289
|
-
];
|
|
3290
|
-
function copyPasteDemoLines(preset, words, language) {
|
|
3291
|
-
const lines = [
|
|
3292
|
-
`## ${words.copyDemos}`,
|
|
3293
|
-
"",
|
|
3294
|
-
words.copyDemosBody,
|
|
3295
|
-
""
|
|
3296
|
-
];
|
|
3297
|
-
for (const key of README_DEMO_ORDER) {
|
|
3298
|
-
const packageName = demoPackage(key);
|
|
3299
|
-
if (!hasPlugin(preset, packageName)) continue;
|
|
3300
|
-
const demo = README_DEMOS[key];
|
|
3301
|
-
lines.push(`### ${demo.title[language]}`, "");
|
|
3302
|
-
lines.push(demo.intro[language], "");
|
|
3303
|
-
lines.push(demo.markdown, "");
|
|
3304
|
-
}
|
|
3305
|
-
return lines;
|
|
3306
|
-
}
|
|
3307
|
-
function server() {
|
|
3308
|
-
return `import { mountRiebeckiteEndpoints } from "@riebeckite/honox/server";
|
|
3309
|
-
import { createApp } from "honox/server";
|
|
3310
|
-
import { config } from "./config";
|
|
3311
|
-
import { content } from "./content";
|
|
3312
|
-
|
|
3313
|
-
const app = createApp({
|
|
3314
|
-
init: (app) => {
|
|
3315
|
-
mountRiebeckiteEndpoints(app, { config, content });
|
|
3316
|
-
},
|
|
3317
|
-
});
|
|
3318
|
-
|
|
3319
|
-
export default app;
|
|
3320
|
-
export { config, content };
|
|
3321
|
-
`;
|
|
3322
|
-
}
|
|
3323
|
-
function client() {
|
|
3324
|
-
return `import { initRiebeckiteClient } from "virtual:riebeckite/client";
|
|
3325
|
-
import { createClient } from "honox/client";
|
|
3326
|
-
|
|
3327
|
-
createClient();
|
|
3328
|
-
|
|
3329
|
-
if (document.readyState === "loading") {
|
|
3330
|
-
document.addEventListener("DOMContentLoaded", initPage, { once: true });
|
|
3331
|
-
} else {
|
|
3332
|
-
initPage();
|
|
3333
|
-
}
|
|
3334
|
-
|
|
3335
|
-
function initPage() {
|
|
3336
|
-
initRiebeckiteClient();
|
|
3337
|
-
}
|
|
3338
|
-
`;
|
|
3339
|
-
}
|
|
3340
|
-
function appConfig() {
|
|
3341
|
-
return `import path from "node:path";
|
|
3342
|
-
import { fileURLToPath } from "node:url";
|
|
3343
|
-
import { resolveConfigModule } from "@riebeckite/core";
|
|
3344
|
-
import * as rawConfigModule from "../riebeckite.config";
|
|
3345
|
-
|
|
3346
|
-
const appRoot =
|
|
3347
|
-
process.env.RIEBECKITE_APP_ROOT ??
|
|
3348
|
-
fileURLToPath(new URL("../", import.meta.url));
|
|
3349
|
-
const resolvedConfig = resolveConfigModule(rawConfigModule);
|
|
3350
|
-
|
|
3351
|
-
export const config = {
|
|
3352
|
-
...resolvedConfig,
|
|
3353
|
-
buildDirectory: path.join(appRoot, ".riebeckite"),
|
|
3354
|
-
content: {
|
|
3355
|
-
...resolvedConfig.content,
|
|
3356
|
-
directory: path.resolve(appRoot, resolvedConfig.content.directory),
|
|
3492
|
+
" href: https://example.com/themes/default/",
|
|
3493
|
+
" - title: Minimal",
|
|
3494
|
+
" description: Stripped back to the essentials.",
|
|
3495
|
+
" meta: v0.0.5",
|
|
3496
|
+
" href: https://example.com/themes/minimal/",
|
|
3497
|
+
" - title: Gruvbox",
|
|
3498
|
+
" description: A warm, high-contrast palette.",
|
|
3499
|
+
" meta: v0.0.5",
|
|
3500
|
+
" href: https://example.com/themes/gruvbox/"
|
|
3501
|
+
].join("\n")
|
|
3502
|
+
)
|
|
3357
3503
|
},
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3504
|
+
"@riebeckite/plugin-dataview": {
|
|
3505
|
+
title: { en: "Dataview", ja: "Dataview" },
|
|
3506
|
+
intro: {
|
|
3507
|
+
en: "A `dataview` query renders a table of notes from the manifest.",
|
|
3508
|
+
ja: "`dataview` クエリがマニフェストからノート一覧を描画します。"
|
|
3509
|
+
},
|
|
3510
|
+
markdown: fence(
|
|
3511
|
+
"dataview",
|
|
3512
|
+
[
|
|
3513
|
+
'TABLE file.name AS "Name", status',
|
|
3514
|
+
"FROM #project",
|
|
3515
|
+
'WHERE status = "active"',
|
|
3516
|
+
"SORT file.name asc",
|
|
3517
|
+
"LIMIT 10"
|
|
3518
|
+
].join("\n")
|
|
3519
|
+
)
|
|
3372
3520
|
},
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
"
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
}
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
if (!preset.theme) {
|
|
3454
|
-
blocks.push(
|
|
3455
|
-
".riebeckite-empty {",
|
|
3456
|
-
" max-width: 48rem;",
|
|
3457
|
-
" padding: 4rem 1rem;",
|
|
3458
|
-
" margin: 0 auto;",
|
|
3459
|
-
"}",
|
|
3460
|
-
""
|
|
3461
|
-
);
|
|
3462
|
-
}
|
|
3463
|
-
return [...imports, ...blocks].join("\n");
|
|
3464
|
-
}
|
|
3465
|
-
function siteHeader() {
|
|
3466
|
-
return `import { ColorModeToggle } from "@riebeckite/plugin-color-mode";
|
|
3467
|
-
import { config } from "../config";
|
|
3468
|
-
|
|
3469
|
-
export function SiteHeader() {
|
|
3470
|
-
return (
|
|
3471
|
-
<header class="site-header">
|
|
3472
|
-
<a href="/" class="site-header__home">
|
|
3473
|
-
{config.site.title}
|
|
3474
|
-
</a>
|
|
3475
|
-
<ColorModeToggle />
|
|
3476
|
-
</header>
|
|
3477
|
-
);
|
|
3478
|
-
}
|
|
3479
|
-
`;
|
|
3480
|
-
}
|
|
3481
|
-
function article() {
|
|
3482
|
-
return `import type { PostContent } from "@riebeckite/core";
|
|
3483
|
-
import { Article, ArticleContent, ArticleLayout } from "@riebeckite/honox/ui";
|
|
3484
|
-
|
|
3485
|
-
export function SiteArticle({
|
|
3486
|
-
post,
|
|
3487
|
-
afterMeta,
|
|
3488
|
-
}: {
|
|
3489
|
-
post: PostContent;
|
|
3490
|
-
afterMeta?: string;
|
|
3491
|
-
}) {
|
|
3492
|
-
return (
|
|
3493
|
-
<Article class="site-article">
|
|
3494
|
-
<ArticleLayout>
|
|
3495
|
-
<ArticleContent>
|
|
3496
|
-
{afterMeta ? (
|
|
3497
|
-
<div
|
|
3498
|
-
class="site-article__after-meta"
|
|
3499
|
-
dangerouslySetInnerHTML={{ __html: afterMeta }}
|
|
3500
|
-
/>
|
|
3501
|
-
) : null}
|
|
3502
|
-
<div dangerouslySetInnerHTML={{ __html: post.html ?? "" }} />
|
|
3503
|
-
</ArticleContent>
|
|
3504
|
-
</ArticleLayout>
|
|
3505
|
-
</Article>
|
|
3506
|
-
);
|
|
3507
|
-
}
|
|
3508
|
-
`;
|
|
3509
|
-
}
|
|
3510
|
-
function renderer(preset) {
|
|
3511
|
-
if (!preset.theme) return bareRenderer();
|
|
3512
|
-
const hasHeader = preset.appFiles.includes("header");
|
|
3513
|
-
const hasColorMode = preset.plugins.some(
|
|
3514
|
-
(plugin) => plugin.package === "@riebeckite/plugin-color-mode"
|
|
3515
|
-
);
|
|
3516
|
-
return `import type { PluginHeadTag } from "@riebeckite/core";
|
|
3517
|
-
import { jsxRenderer } from "hono/jsx-renderer";
|
|
3518
|
-
import { Link, Script } from "honox/server";
|
|
3519
|
-
${hasColorMode ? `import { ColorModeScript } from "@riebeckite/plugin-color-mode";
|
|
3520
|
-
` : ""}${hasHeader ? `import { SiteHeader } from "../components/site-header";
|
|
3521
|
-
` : ""}import { config } from "../config";
|
|
3522
|
-
|
|
3523
|
-
function themeAttributes() {
|
|
3524
|
-
const { theme } = config;
|
|
3525
|
-
|
|
3526
|
-
return {
|
|
3527
|
-
...theme.attributes,
|
|
3528
|
-
"data-theme": theme.colorMode === "system" ? undefined : theme.colorMode,
|
|
3529
|
-
"data-theme-name": theme.name,
|
|
3530
|
-
"data-typography": theme.typography,
|
|
3531
|
-
"data-article-layout": theme.articleLayout,
|
|
3532
|
-
};
|
|
3521
|
+
"@riebeckite/plugin-query": {
|
|
3522
|
+
title: { en: "Query", ja: "Query" },
|
|
3523
|
+
intro: {
|
|
3524
|
+
en: "A `query` fence is YAML that filters and sorts entries from the manifest.",
|
|
3525
|
+
ja: "`query` フェンスの YAML でマニフェストのエントリを絞り込み・並べ替えできます。"
|
|
3526
|
+
},
|
|
3527
|
+
markdown: fence(
|
|
3528
|
+
"query",
|
|
3529
|
+
[
|
|
3530
|
+
"filter:",
|
|
3531
|
+
" tags:",
|
|
3532
|
+
" any: [diary]",
|
|
3533
|
+
"sort:",
|
|
3534
|
+
" field: date",
|
|
3535
|
+
" order: desc",
|
|
3536
|
+
"limit: 5"
|
|
3537
|
+
].join("\n")
|
|
3538
|
+
)
|
|
3539
|
+
},
|
|
3540
|
+
"@riebeckite/plugin-bases": {
|
|
3541
|
+
title: { en: "Base views", ja: "Base ビュー" },
|
|
3542
|
+
intro: {
|
|
3543
|
+
en: "A `base` YAML fence renders a Base table view.",
|
|
3544
|
+
ja: "`base` YAML フェンスが Base のテーブルビューを描画します。"
|
|
3545
|
+
},
|
|
3546
|
+
markdown: fence(
|
|
3547
|
+
"base",
|
|
3548
|
+
[
|
|
3549
|
+
"filters:",
|
|
3550
|
+
" and:",
|
|
3551
|
+
' - file.hasTag("featured")',
|
|
3552
|
+
"properties:",
|
|
3553
|
+
" file.name:",
|
|
3554
|
+
" displayName: Title",
|
|
3555
|
+
"views:",
|
|
3556
|
+
" - type: table",
|
|
3557
|
+
" name: Featured",
|
|
3558
|
+
" limit: 10"
|
|
3559
|
+
].join("\n")
|
|
3560
|
+
)
|
|
3561
|
+
},
|
|
3562
|
+
"@riebeckite/plugin-kanban": {
|
|
3563
|
+
title: { en: "Kanban boards", ja: "カンバンボード" },
|
|
3564
|
+
intro: {
|
|
3565
|
+
en: "A note whose body is `##` columns of task lists becomes a board; `#tags` and `[[wikilinks]]` work inside cards.",
|
|
3566
|
+
ja: "本文が `##` 列とタスクリストでできたノートはボードになります。カード内では `#タグ` や `[[ウィキリンク]]` も使えます。"
|
|
3567
|
+
},
|
|
3568
|
+
markdown: fence(
|
|
3569
|
+
"md",
|
|
3570
|
+
[
|
|
3571
|
+
"## Backlog",
|
|
3572
|
+
"",
|
|
3573
|
+
"- [ ] Draft the release notes",
|
|
3574
|
+
"- [ ] Link to [[index]]",
|
|
3575
|
+
"",
|
|
3576
|
+
"## Done",
|
|
3577
|
+
"",
|
|
3578
|
+
"- [x] Publish the fixture"
|
|
3579
|
+
].join("\n")
|
|
3580
|
+
)
|
|
3581
|
+
}
|
|
3582
|
+
};
|
|
3583
|
+
var README_PAGE_LINKS = {
|
|
3584
|
+
"framework/plugins": { en: "Plugin tour", ja: "プラグインツアー" },
|
|
3585
|
+
"framework/themes": { en: "Theme tour", ja: "テーマツアー" },
|
|
3586
|
+
guide: { en: "Getting-started guide", ja: "はじめにガイド" },
|
|
3587
|
+
examples: { en: "Examples", ja: "サンプル集" },
|
|
3588
|
+
"reference/plugins": { en: "Plugin reference", ja: "プラグインリファレンス" },
|
|
3589
|
+
"reference/themes": { en: "Theme reference", ja: "テーマリファレンス" }
|
|
3590
|
+
};
|
|
3591
|
+
var ENGLISH_ONLY_PAGES = /* @__PURE__ */ new Set([
|
|
3592
|
+
"guide",
|
|
3593
|
+
"reference/plugins",
|
|
3594
|
+
"reference/themes"
|
|
3595
|
+
]);
|
|
3596
|
+
function fence(language, body) {
|
|
3597
|
+
const tick = "```";
|
|
3598
|
+
return `${tick}${language}
|
|
3599
|
+
${body}
|
|
3600
|
+
${tick}`;
|
|
3533
3601
|
}
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
const headTags: readonly PluginHeadTag[] = c.get("headTags") ?? [];
|
|
3537
|
-
|
|
3538
|
-
return (
|
|
3539
|
-
<html
|
|
3540
|
-
lang={c.get("htmlLanguage") ?? config.site.locale}
|
|
3541
|
-
{...themeAttributes()}
|
|
3542
|
-
>
|
|
3543
|
-
<head>
|
|
3544
|
-
<meta charset="utf-8" />
|
|
3545
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
3546
|
-
<title>{config.site.title}</title>
|
|
3547
|
-
${hasColorMode ? ` <ColorModeScript />
|
|
3548
|
-
` : ""} <Link href="/app/style.css" rel="stylesheet" />
|
|
3549
|
-
{headTags.map(renderHeadTag)}
|
|
3550
|
-
<Script src="/app/client.ts" async />
|
|
3551
|
-
</head>
|
|
3552
|
-
<body class="riebeckite-page">
|
|
3553
|
-
${hasHeader ? ` <SiteHeader />
|
|
3554
|
-
` : ""} {children}
|
|
3555
|
-
</body>
|
|
3556
|
-
</html>
|
|
3557
|
-
);
|
|
3558
|
-
});
|
|
3559
|
-
|
|
3560
|
-
function renderHeadTag(tag: PluginHeadTag, index: number) {
|
|
3561
|
-
const key = \`\${tag.tag}-\${index}\`;
|
|
3562
|
-
if (tag.tag === "meta") return <meta {...tag.attrs} key={key} />;
|
|
3563
|
-
if (tag.tag === "link") return <link {...tag.attrs} key={key} />;
|
|
3564
|
-
return (
|
|
3565
|
-
<script
|
|
3566
|
-
{...tag.attrs}
|
|
3567
|
-
key={key}
|
|
3568
|
-
dangerouslySetInnerHTML={
|
|
3569
|
-
tag.children ? { __html: tag.children } : undefined
|
|
3570
|
-
}
|
|
3571
|
-
/>
|
|
3572
|
-
);
|
|
3602
|
+
function hasPlugin(preset, packageName) {
|
|
3603
|
+
return preset.plugins.some((plugin) => plugin.package === packageName);
|
|
3573
3604
|
}
|
|
3574
|
-
|
|
3605
|
+
function demoPackage(key) {
|
|
3606
|
+
return key.split("/", 2).join("/");
|
|
3575
3607
|
}
|
|
3576
|
-
function
|
|
3577
|
-
return
|
|
3578
|
-
import { Link, Script } from "honox/server";
|
|
3579
|
-
import { config } from "../config";
|
|
3580
|
-
|
|
3581
|
-
export default jsxRenderer(({ children }, c) => (
|
|
3582
|
-
<html lang={c.get("htmlLanguage") ?? config.site.locale}>
|
|
3583
|
-
<head>
|
|
3584
|
-
<meta charset="utf-8" />
|
|
3585
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
3586
|
-
<title>{config.site.title}</title>
|
|
3587
|
-
<Link href="/app/style.css" rel="stylesheet" />
|
|
3588
|
-
<Script src="/app/client.ts" async />
|
|
3589
|
-
</head>
|
|
3590
|
-
<body class="riebeckite-page">{children}</body>
|
|
3591
|
-
</html>
|
|
3592
|
-
));
|
|
3593
|
-
`;
|
|
3608
|
+
function readmePluginOptions(variables, preset, plugin) {
|
|
3609
|
+
return renderOptions(plugin.options, optionContext(preset, variables));
|
|
3594
3610
|
}
|
|
3595
|
-
function
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
const indexEntry = manifest.bySlug.get("index");
|
|
3606
|
-
if (indexEntry && indexEntry.permalink !== "/") {
|
|
3607
|
-
return c.redirect(indexEntry.permalink, 308);
|
|
3608
|
-
}
|
|
3609
|
-
|
|
3610
|
-
const post = await content.getProcessedContent("index");
|
|
3611
|
-
if (!isPublished(config, post.frontmatter)) {
|
|
3612
|
-
return c.notFound();
|
|
3613
|
-
}
|
|
3614
|
-
|
|
3615
|
-
if (indexEntry) {
|
|
3616
|
-
c.set("htmlLanguage", indexEntry.publicLocation.metadata?.["l10n.lang"]);
|
|
3617
|
-
c.set("headTags", indexEntry.headTags ?? []);
|
|
3611
|
+
function configurationReferenceLines(preset, variables, words) {
|
|
3612
|
+
const lines = [
|
|
3613
|
+
`## ${words.configReference}`,
|
|
3614
|
+
"",
|
|
3615
|
+
words.configReferenceBody,
|
|
3616
|
+
""
|
|
3617
|
+
];
|
|
3618
|
+
if (preset.theme) {
|
|
3619
|
+
const themeCall = preset.theme.options ? `${preset.theme.factory}(${preset.theme.options})` : `${preset.theme.factory}()`;
|
|
3620
|
+
lines.push(`- **${words.theme}**: \`${themeCall}\``, "");
|
|
3618
3621
|
}
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
post={post}
|
|
3623
|
-
afterMeta={indexEntry?.bodySlots?.["article.after-meta"]}
|
|
3624
|
-
/>,
|
|
3622
|
+
lines.push(
|
|
3623
|
+
`| Package | ${words.factory} | ${words.options} |`,
|
|
3624
|
+
"| --- | --- | --- |"
|
|
3625
3625
|
);
|
|
3626
|
-
|
|
3627
|
-
|
|
3626
|
+
for (const plugin of preset.plugins) {
|
|
3627
|
+
const options = readmePluginOptions(variables, preset, plugin);
|
|
3628
|
+
const cell = options === null ? words.emDash : `\`${options}\``;
|
|
3629
|
+
lines.push(`| \`${plugin.package}\` | \`${plugin.factory}\` | ${cell} |`);
|
|
3630
|
+
}
|
|
3631
|
+
lines.push("");
|
|
3632
|
+
return lines;
|
|
3628
3633
|
}
|
|
3629
|
-
function
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
);
|
|
3641
|
-
`;
|
|
3634
|
+
function demoPagesLines(preset, variables, words, language) {
|
|
3635
|
+
const lines = [
|
|
3636
|
+
`## ${words.demoPages}`,
|
|
3637
|
+
"",
|
|
3638
|
+
words.demoPagesBody,
|
|
3639
|
+
""
|
|
3640
|
+
];
|
|
3641
|
+
const defaultLang = defaultLanguageForLocale(variables.locale);
|
|
3642
|
+
const pages = preset.contentPages.filter((page) => page !== "index");
|
|
3643
|
+
for (const page of pages) {
|
|
3644
|
+
const label = README_PAGE_LINKS[page]?.[language] ?? `/${page}/`;
|
|
3645
|
+
const suffix = ENGLISH_ONLY_PAGES.has(page) && defaultLang !== "en" ? ".en" : "";
|
|
3646
|
+
const source = `content/${page}${suffix}.md`;
|
|
3647
|
+
const url = `/${page}/`;
|
|
3648
|
+
lines.push(`- [**${label}**](${source}) — live at [\`${url}\`](${url})`);
|
|
3649
|
+
}
|
|
3650
|
+
lines.push("");
|
|
3651
|
+
return lines;
|
|
3642
3652
|
}
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
const
|
|
3674
|
-
if (!
|
|
3675
|
-
|
|
3676
|
-
}
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
return c.render(
|
|
3682
|
-
<SiteArticle
|
|
3683
|
-
post={post}
|
|
3684
|
-
afterMeta={route.entry.bodySlots?.["article.after-meta"]}
|
|
3685
|
-
/>,
|
|
3686
|
-
);
|
|
3687
|
-
},
|
|
3688
|
-
);
|
|
3689
|
-
`;
|
|
3653
|
+
var README_DEMO_ORDER = [
|
|
3654
|
+
"@riebeckite/plugin-obsidian-markdown/callout",
|
|
3655
|
+
"@riebeckite/plugin-obsidian-markdown/wikilinks",
|
|
3656
|
+
"@riebeckite/plugin-code-enhance",
|
|
3657
|
+
"@riebeckite/plugin-code-tabs",
|
|
3658
|
+
"@riebeckite/plugin-mermaid",
|
|
3659
|
+
"@riebeckite/plugin-d2",
|
|
3660
|
+
"@riebeckite/plugin-graphviz",
|
|
3661
|
+
"@riebeckite/plugin-chartjs",
|
|
3662
|
+
"@riebeckite/plugin-vega-lite",
|
|
3663
|
+
"@riebeckite/plugin-wavedrom",
|
|
3664
|
+
"@riebeckite/plugin-markmap",
|
|
3665
|
+
"@riebeckite/plugin-map",
|
|
3666
|
+
"@riebeckite/plugin-marp",
|
|
3667
|
+
"@riebeckite/plugin-qr-code",
|
|
3668
|
+
"@riebeckite/plugin-rich-embed",
|
|
3669
|
+
"@riebeckite/plugin-gallery",
|
|
3670
|
+
"@riebeckite/plugin-dataview",
|
|
3671
|
+
"@riebeckite/plugin-query",
|
|
3672
|
+
"@riebeckite/plugin-bases",
|
|
3673
|
+
"@riebeckite/plugin-kanban"
|
|
3674
|
+
];
|
|
3675
|
+
function copyPasteDemoLines(preset, words, language) {
|
|
3676
|
+
const lines = [
|
|
3677
|
+
`## ${words.copyDemos}`,
|
|
3678
|
+
"",
|
|
3679
|
+
words.copyDemosBody,
|
|
3680
|
+
""
|
|
3681
|
+
];
|
|
3682
|
+
for (const key of README_DEMO_ORDER) {
|
|
3683
|
+
const packageName = demoPackage(key);
|
|
3684
|
+
if (!hasPlugin(preset, packageName)) continue;
|
|
3685
|
+
const demo = README_DEMOS[key];
|
|
3686
|
+
lines.push(`### ${demo.title[language]}`, "");
|
|
3687
|
+
lines.push(demo.intro[language], "");
|
|
3688
|
+
lines.push(demo.markdown, "");
|
|
3689
|
+
}
|
|
3690
|
+
return lines;
|
|
3690
3691
|
}
|
|
3691
3692
|
|
|
3692
3693
|
// src/scaffold/index.ts
|