meowpress 0.3.0-alpha.6 → 0.3.0-alpha.8
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/README.md +11 -4
- package/dist/src/build.js +11 -4
- package/dist/src/locale.d.ts +1 -1
- package/dist/src/locale.js +18 -3
- package/dist/src/site.js +23 -21
- package/dist/src/skills.d.ts +2 -0
- package/dist/src/skills.js +12 -0
- package/dist/src/theme.js +13 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,6 +70,11 @@ owns `dist/`, set `outputDirectory` to a separate directory and reserve it for g
|
|
|
70
70
|
to choose the root for those skills. Set `notFound: false` to omit the built-in `404.html`, or
|
|
71
71
|
supply `notFound: { title, message, homeLabel }` to change its copy.
|
|
72
72
|
|
|
73
|
+
A skill's `SKILL.md` may declare the language of its material: `lang: zh` in the frontmatter, or
|
|
74
|
+
`lang: zh` under `metadata`. The build then marks the skill's material with that language on
|
|
75
|
+
every page that shows it, so a page in another language says what the material is written in. A
|
|
76
|
+
skill that declares no language keeps the page's own.
|
|
77
|
+
|
|
73
78
|
## Site URL and time zone
|
|
74
79
|
|
|
75
80
|
`site.url` is the public origin of the site, without a path, such as `https://example.com`. It is
|
|
@@ -118,10 +123,12 @@ export default meowSite({
|
|
|
118
123
|
each link `label`, and the three `notFound` strings. The source tree prints them as written.
|
|
119
124
|
`agentGuide` is not translated.
|
|
120
125
|
- Each target gets `/<tag>/` (home), `/<tag>/about/`, `/<tag>/posts/`, `/<tag>/thoughts/`,
|
|
121
|
-
`/<tag>/404.html` (a host decides whether it serves the
|
|
122
|
-
written in that language. Dates follow the page locale.
|
|
123
|
-
helper that points a route
|
|
124
|
-
|
|
126
|
+
`/<tag>/skills/` with a page per skill, `/<tag>/404.html` (a host decides whether it serves the
|
|
127
|
+
file) and a page for every content item written in that language. Dates follow the page locale.
|
|
128
|
+
Every internal link goes through one helper that points a route to the tree that publishes it.
|
|
129
|
+
- Skill files are repository material and are not translated: every tree publishes the same skill
|
|
130
|
+
pages, with the theme in that tree's language and the material in the language the skill
|
|
131
|
+
declares. The source tree links the root agent indexes; a target links its own.
|
|
125
132
|
- With more than one locale the header shows a script-free language switch that points to the same
|
|
126
133
|
page where the translation exists and to that locale's home otherwise. With `site.url`, pages
|
|
127
134
|
also carry `<link rel="canonical">`, one `<link rel="alternate" hreflang>` per version and
|
package/dist/src/build.js
CHANGED
|
@@ -13,6 +13,10 @@ import { loadSkills } from "./skills.js";
|
|
|
13
13
|
import { contentRoute, reportedPath, translationReport } from "./translations.js";
|
|
14
14
|
import { sitePageFile, sitePageMarkdownFile } from "./pages.js";
|
|
15
15
|
import { publishSite, validateBuildDestination, validateOutputDirectory } from "./output.js";
|
|
16
|
+
/** The output path of a skill page, below the tree of the locale that renders it. */
|
|
17
|
+
function skillPathOf(skill) {
|
|
18
|
+
return skill.scope === "public" ? `skills/${skill.slug}` : `skills/project/${skill.slug}`;
|
|
19
|
+
}
|
|
16
20
|
export { sitePageMarkdownFile } from "./pages.js";
|
|
17
21
|
/** Validate the origin of `site.url` and store it without a trailing slash. */
|
|
18
22
|
function resolveSiteUrl(value) {
|
|
@@ -360,16 +364,19 @@ async function writeSite(config, generatedDirectory) {
|
|
|
360
364
|
})))));
|
|
361
365
|
}
|
|
362
366
|
for (const skill of skills) {
|
|
363
|
-
|
|
364
|
-
entrypoints.push(await writePage(generatedDirectory, `${skillPath}/index.html`, skillPage(skill, config.theme, config.site, config.themeStylesheet, rootLocale)));
|
|
367
|
+
entrypoints.push(await writePage(generatedDirectory, `${skillPathOf(skill)}/index.html`, skillPage(skill, config.theme, config.site, config.themeStylesheet, rootLocale)));
|
|
365
368
|
}
|
|
366
|
-
//
|
|
367
|
-
//
|
|
369
|
+
// Every locale tree publishes the same pages, each with its own locale: home, About, the two
|
|
370
|
+
// archives, the skills index and a page for every skill (the skill material is the
|
|
371
|
+
// repository's own and stays in the language it is written in), a 404, and a page for each
|
|
372
|
+
// content item written in that language.
|
|
368
373
|
for (const tree of targetTrees) {
|
|
369
374
|
const prefix = `${tree.target.segment}/`;
|
|
370
375
|
entrypoints.push(...(await Promise.all([
|
|
371
376
|
writePage(generatedDirectory, `${prefix}index.html`, homePage(tree.timeline, config.theme, config.site, config.themeStylesheet, tree.locale)),
|
|
372
377
|
writePage(generatedDirectory, `${prefix}about/index.html`, aboutPage(config.theme, config.site, config.themeStylesheet, tree.locale)),
|
|
378
|
+
writePage(generatedDirectory, `${prefix}skills/index.html`, skillsIndexPage(skills, config.theme, config.site, config.themeStylesheet, tree.locale)),
|
|
379
|
+
...skills.map((skill) => writePage(generatedDirectory, `${prefix}${skillPathOf(skill)}/index.html`, skillPage(skill, config.theme, config.site, config.themeStylesheet, tree.locale))),
|
|
373
380
|
writePage(generatedDirectory, `${prefix}posts/index.html`, listPage("post", tree.posts, config.theme, config.site, config.themeStylesheet, tree.locale)),
|
|
374
381
|
writePage(generatedDirectory, `${prefix}thoughts/index.html`, listPage("thought", tree.thoughts, config.theme, config.site, config.themeStylesheet, tree.locale)),
|
|
375
382
|
])), ...(await writeContentPages(generatedDirectory, localizedItems(posts, tree.target.tag), localizedItems(thoughts, tree.target.tag), config.theme, config.site, config.themeStylesheet, tree.locale)));
|
package/dist/src/locale.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export declare function createPageLocale(options: PageLocaleOptions): PageLocale
|
|
|
54
54
|
/** The locale every page function uses when the caller passes none. */
|
|
55
55
|
export declare function defaultPageLocale(): PageLocale;
|
|
56
56
|
/** The URL of an internal route for a locale. Every internal link of the theme goes through
|
|
57
|
-
* it.
|
|
57
|
+
* it. Every route it knows is published in every locale tree. */
|
|
58
58
|
export declare function localePath(locale: PageLocale, path: string): string;
|
|
59
59
|
/**
|
|
60
60
|
* The URL of a content item, in the tree of the language it is written in. An original in the
|
package/dist/src/locale.js
CHANGED
|
@@ -80,11 +80,26 @@ export function defaultPageLocale() {
|
|
|
80
80
|
return english;
|
|
81
81
|
}
|
|
82
82
|
/** Routes that exist once per locale; every other route exists only in the source tree. */
|
|
83
|
-
const TRANSLATED_ROUTES = new Set([
|
|
83
|
+
const TRANSLATED_ROUTES = new Set([
|
|
84
|
+
"/",
|
|
85
|
+
"/posts/",
|
|
86
|
+
"/thoughts/",
|
|
87
|
+
"/about/",
|
|
88
|
+
"/skills/",
|
|
89
|
+
]);
|
|
90
|
+
/** Routes whose pages below them exist once per locale too. The content sections are not
|
|
91
|
+
* here: their pages live in the tree of the language they are written in. */
|
|
92
|
+
const TRANSLATED_SECTIONS = new Set(["/skills/"]);
|
|
93
|
+
/** Whether a route is published in every locale tree, the pages below it included. */
|
|
94
|
+
function isTranslatedRoute(path) {
|
|
95
|
+
if (TRANSLATED_ROUTES.has(path))
|
|
96
|
+
return true;
|
|
97
|
+
return [...TRANSLATED_SECTIONS].some((section) => path.startsWith(section));
|
|
98
|
+
}
|
|
84
99
|
/** The URL of an internal route for a locale. Every internal link of the theme goes through
|
|
85
|
-
* it.
|
|
100
|
+
* it. Every route it knows is published in every locale tree. */
|
|
86
101
|
export function localePath(locale, path) {
|
|
87
|
-
if (locale.segment === "" || !
|
|
102
|
+
if (locale.segment === "" || !isTranslatedRoute(path))
|
|
88
103
|
return path;
|
|
89
104
|
return `/${locale.segment}${path}`;
|
|
90
105
|
}
|
package/dist/src/site.js
CHANGED
|
@@ -56,20 +56,6 @@ function contentPage(locale, item) {
|
|
|
56
56
|
}),
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
/**
|
|
60
|
-
* A page that exists once, in the source language, such as a skill. The switch still shows every
|
|
61
|
-
* locale and sends the others to their home page, so a target reader is not stranded.
|
|
62
|
-
*/
|
|
63
|
-
function sourceOnlyPage(locale, path) {
|
|
64
|
-
if (locale.entries.length < 2)
|
|
65
|
-
return undefined;
|
|
66
|
-
return {
|
|
67
|
-
path,
|
|
68
|
-
versions: locale.entries
|
|
69
|
-
.filter((entry) => entry.isSource)
|
|
70
|
-
.map((entry) => ({ tag: entry.tag, label: entry.label, href: path })),
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
59
|
/** An absolute URL for alternate and canonical links; `site.url` has no trailing slash. */
|
|
74
60
|
function absoluteHref(site, path) {
|
|
75
61
|
return site.url === undefined ? path : `${site.url}${path}`;
|
|
@@ -120,6 +106,10 @@ function SiteHeader({ activePath, site, locale, page, }) {
|
|
|
120
106
|
h("nav", { className: "site-nav", "aria-label": text(locale, M.primaryNavigation) }, links.map(([href, label]) => (h("a", { href: localePath(locale, href), "aria-current": activePath === href ? "page" : undefined }, text(locale, label))))),
|
|
121
107
|
h(LanguageSwitch, { locale: locale, page: page })));
|
|
122
108
|
}
|
|
109
|
+
/** The agent index a tree publishes next to its pages: at the root for the source, else the segment. */
|
|
110
|
+
function indexHref(locale, file) {
|
|
111
|
+
return locale.segment === "" ? `/${file}` : `/${locale.segment}/${file}`;
|
|
112
|
+
}
|
|
123
113
|
function SiteFooter({ site, locale }) {
|
|
124
114
|
return (h("footer", { className: "site-footer" },
|
|
125
115
|
h(Text, { variant: "caption" }, text(locale, M.footerCopyright, {
|
|
@@ -127,8 +117,8 @@ function SiteFooter({ site, locale }) {
|
|
|
127
117
|
name: site.name,
|
|
128
118
|
})),
|
|
129
119
|
h(Inline, { gap: "compact" },
|
|
130
|
-
h("a", { href: "
|
|
131
|
-
h("a", { href: "
|
|
120
|
+
h("a", { href: indexHref(locale, "llm.txt") }, "llm.txt"),
|
|
121
|
+
h("a", { href: indexHref(locale, "agents.md") }, "agents.md"))));
|
|
132
122
|
}
|
|
133
123
|
function Document({ title, description, activePath, styleHref, baseHref, wide, children, theme, site, locale, page, }) {
|
|
134
124
|
// Compare with the configured name before it is translated.
|
|
@@ -418,13 +408,24 @@ const code = (children) => h("code", null, children);
|
|
|
418
408
|
function skillUrl(skill) {
|
|
419
409
|
return skill.scope === "public" ? `/skills/${skill.slug}/` : `/skills/project/${skill.slug}/`;
|
|
420
410
|
}
|
|
411
|
+
/**
|
|
412
|
+
* The language of the skill material, when the repository declares one and the page is written
|
|
413
|
+
* in another. Skill files are repository material and are not translated, so a tree that is not
|
|
414
|
+
* the material's language marks it as such.
|
|
415
|
+
*/
|
|
416
|
+
function skillLang(skill, locale) {
|
|
417
|
+
if (!skill.lang || skill.lang === locale.tag)
|
|
418
|
+
return undefined;
|
|
419
|
+
return skill.lang;
|
|
420
|
+
}
|
|
421
421
|
function skillInstallCommand(site, skill) {
|
|
422
422
|
return site.skillsPackage
|
|
423
423
|
? `npx skills add ${site.skillsPackage} --skill ${skill.slug}`
|
|
424
424
|
: skill.sourceBasePath;
|
|
425
425
|
}
|
|
426
426
|
function SkillCard({ skill, site, locale, }) {
|
|
427
|
-
|
|
427
|
+
const lang = skillLang(skill, locale);
|
|
428
|
+
return (h(Entry, { href: localePath(locale, skillUrl(skill)), title: lang ? h("span", { lang: lang }, skill.name) : skill.name, description: lang ? h("span", { lang: lang }, skill.description) : skill.description, eyebrow: text(locale, skill.scope === "project" ? M.projectSkillEyebrow : M.publicSkillEyebrow), meta: h(MetaRow, { items: [
|
|
428
429
|
{ label: text(locale, M.markdownFiles, { count: count(skill.files.length) }) },
|
|
429
430
|
{ label: text(locale, M.references, { count: count(skill.relations.length) }) },
|
|
430
431
|
] }) },
|
|
@@ -635,7 +636,7 @@ export function skillsIndexPage(skills, theme = blogTheme, site = DEFAULT_SITE,
|
|
|
635
636
|
title: text(locale, M.skills),
|
|
636
637
|
description: text(locale, M.skillsIndexDescription),
|
|
637
638
|
activePath: "/skills/",
|
|
638
|
-
page:
|
|
639
|
+
page: staticPage(locale, "/skills/"),
|
|
639
640
|
styleHref: styleHref(1 + localeDepth(locale), stylesheet),
|
|
640
641
|
children: (h(Page, { eyebrow: "~/skills", title: text(locale, M.skills), description: text(locale, M.skillsIntro) },
|
|
641
642
|
h(Section, { title: text(locale, M.publicSkills) }, publicSkills.length ? (h(EntryList, null, publicSkills.map((skill) => (h(SkillCard, { skill: skill, site: site, locale: locale }))))) : (h(Text, { variant: "secondary" }, text(locale, M.publicSkillsEmpty)))),
|
|
@@ -646,6 +647,7 @@ export function skillsIndexPage(skills, theme = blogTheme, site = DEFAULT_SITE,
|
|
|
646
647
|
}
|
|
647
648
|
export function skillPage(skill, theme = blogTheme, site = DEFAULT_SITE, stylesheet = DEFAULT_THEME_STYLESHEET, locale = defaultPageLocale()) {
|
|
648
649
|
const firstFile = skill.files[0];
|
|
650
|
+
const lang = skillLang(skill, locale);
|
|
649
651
|
const command = skill.scope === "public" ? skillInstallCommand(site, skill) : skill.sourceBasePath;
|
|
650
652
|
return pageHtml({
|
|
651
653
|
site,
|
|
@@ -655,11 +657,11 @@ export function skillPage(skill, theme = blogTheme, site = DEFAULT_SITE, stylesh
|
|
|
655
657
|
wide: true,
|
|
656
658
|
description: skill.description,
|
|
657
659
|
activePath: "/skills/",
|
|
658
|
-
page:
|
|
660
|
+
page: staticPage(locale, skillUrl(skill)),
|
|
659
661
|
styleHref: skill.scope === "public"
|
|
660
662
|
? styleHref(1 + slugDepth(skill.slug) + localeDepth(locale), stylesheet)
|
|
661
663
|
: styleHref(2 + slugDepth(skill.slug) + localeDepth(locale), stylesheet),
|
|
662
|
-
children: (h(Page, { width: "full", className: "skill-page", title: skill.name, eyebrow: text(locale, M.skill), description: skill.description },
|
|
664
|
+
children: (h(Page, { width: "full", className: "skill-page", title: lang ? h("span", { lang: lang }, skill.name) : skill.name, eyebrow: text(locale, M.skill), description: lang ? h("span", { lang: lang }, skill.description) : skill.description },
|
|
663
665
|
h("a", { className: "skill-back site-icon-label", href: localePath(locale, "/skills/") },
|
|
664
666
|
h(Icon, { name: "arrow-left", size: 14 }),
|
|
665
667
|
" ",
|
|
@@ -684,7 +686,7 @@ export function skillPage(skill, theme = blogTheme, site = DEFAULT_SITE, stylesh
|
|
|
684
686
|
h("header", { className: "skill-viewer-bar" },
|
|
685
687
|
h("span", { "data-current-file": true }, firstFile.path),
|
|
686
688
|
h("span", null, "Markdown")),
|
|
687
|
-
skill.files.map((file, index) => (h(Prose, { as: "article", className: `skill-file-panel${index === 0 ? " active" : ""}`, "data-skill-panel": file.path, hidden: index !== 0, dangerouslySetInnerHTML: {
|
|
689
|
+
skill.files.map((file, index) => (h(Prose, { as: "article", className: `skill-file-panel${index === 0 ? " active" : ""}`, "data-skill-panel": file.path, hidden: index !== 0, lang: lang, dangerouslySetInnerHTML: {
|
|
688
690
|
// The page owns h1; file headings nest under it without dropping any content.
|
|
689
691
|
__html: Bun.markdown
|
|
690
692
|
.html(file.content, { tagFilter: true })
|
package/dist/src/skills.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ export interface Skill {
|
|
|
31
31
|
description: string;
|
|
32
32
|
scope: SkillScope;
|
|
33
33
|
sourceBasePath: string;
|
|
34
|
+
/** The language the skill material is written in, when the repository declares it. */
|
|
35
|
+
lang?: string;
|
|
34
36
|
files: SkillFile[];
|
|
35
37
|
externalNodes: SkillReferenceNode[];
|
|
36
38
|
relations: SkillRelation[];
|
package/dist/src/skills.js
CHANGED
|
@@ -9,6 +9,17 @@ function isRecord(value) {
|
|
|
9
9
|
function textValue(value) {
|
|
10
10
|
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* The language a skill declares for its material: `lang` or `language`, in the frontmatter or
|
|
14
|
+
* under its `metadata`. A skill that declares none has no language of its own.
|
|
15
|
+
*/
|
|
16
|
+
function declaredLang(metadata) {
|
|
17
|
+
const nested = isRecord(metadata.metadata) ? metadata.metadata : {};
|
|
18
|
+
return (textValue(metadata.lang) ??
|
|
19
|
+
textValue(metadata.language) ??
|
|
20
|
+
textValue(nested.lang) ??
|
|
21
|
+
textValue(nested.language));
|
|
22
|
+
}
|
|
12
23
|
function parseDocument(source) {
|
|
13
24
|
const match = source.match(/^---\s*\r?\n([\s\S]*?)\r?\n---\s*(?:\r?\n|$)/);
|
|
14
25
|
if (!match)
|
|
@@ -267,6 +278,7 @@ async function loadSkill(directory, sourceBasePath, scope) {
|
|
|
267
278
|
inferredDescription(entry.body),
|
|
268
279
|
scope,
|
|
269
280
|
sourceBasePath,
|
|
281
|
+
lang: declaredLang(entry.metadata),
|
|
270
282
|
files: markdownPaths.map((path) => {
|
|
271
283
|
const depth = depths.get(path);
|
|
272
284
|
const reachable = depth !== undefined;
|
package/dist/src/theme.js
CHANGED
|
@@ -90,6 +90,19 @@ const siteStyles = css `
|
|
|
90
90
|
gap: ${uiTokens.space.group};
|
|
91
91
|
color: ${uiTokens.ink.tertiary};
|
|
92
92
|
}
|
|
93
|
+
/* The notice's rich message links the original; without a rule the anchor would fall back to
|
|
94
|
+
the browser's default link styling. Match the prose reading rhythm's link treatment. */
|
|
95
|
+
.translation-notices a {
|
|
96
|
+
color: ${uiTokens.accent.ink};
|
|
97
|
+
text-decoration: underline;
|
|
98
|
+
text-decoration-thickness: 1px;
|
|
99
|
+
text-decoration-color: color-mix(in srgb, ${uiTokens.accent.ink} 55%, transparent);
|
|
100
|
+
text-underline-offset: 3px;
|
|
101
|
+
}
|
|
102
|
+
.translation-notices a:hover {
|
|
103
|
+
color: ${uiTokens.ink.primary};
|
|
104
|
+
text-decoration-color: ${uiTokens.ink.primary};
|
|
105
|
+
}
|
|
93
106
|
#main-content {
|
|
94
107
|
padding-block: ${uiTokens.space.pageBlock};
|
|
95
108
|
}
|