@hagicode/hagilight-starlight 0.8.1-dev.87.1.57ea49d → 0.8.1-dev.92.1.85649f3
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 +10 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -41,6 +41,16 @@ Disable the picker to keep Starlight's built-in toggle or compose `@hagicode/hag
|
|
|
41
41
|
hagilight({ themes: { enabled: false } })
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
+
### Body images
|
|
45
|
+
|
|
46
|
+
`hagilight()` registers the content-image plugin from `@hagicode/hagilight-core/content-images` for the whole site. Every Markdown or MDX body image outside a `<picture>` element gets `loading="lazy"`, `decoding="async"`, and the class `hagilight-content-image`. Values the author set are kept, and logos and showcase images are not changed.
|
|
47
|
+
|
|
48
|
+
Turn it off for the site:
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
hagilight({ contentImages: { enabled: false } })
|
|
52
|
+
```
|
|
53
|
+
|
|
44
54
|
### HagiCode showcase
|
|
45
55
|
|
|
46
56
|
After the body (and any translation notice) of every documentation article, the plugin renders a static HagiCode showcase: a headline, lead, and tagline with calls to action to the website and the documentation, three pillars (Smart, Efficient, Fun), a three-image gallery with captions, and a closing row with the Windows download button beside a selectable, copy-ready share sentence. The layout follows the showcase's own width: one column when narrow, a three-up pillar row, a gallery mosaic, and a two-column closing row from 36rem, and the pillars beside the pitch from 56rem (for example in the wide content mode). All text is localized for the ten published locales (`en-US`, `zh-CN`, `zh-Hant`, `ja-JP`, `ko-KR`, `de-DE`, `fr-FR`, `es-ES`, `pt-BR`, `ru-RU`) and falls back to English for any other language. Links come from the same locale-aware catalog as the footer.
|
package/dist/index.d.ts
CHANGED
|
@@ -63,6 +63,8 @@ export interface HagilightStarlightOptions {
|
|
|
63
63
|
hagicodePromotion?: HagilightToggleOptions;
|
|
64
64
|
/** Floating promotion banner rendered after the footer. */
|
|
65
65
|
promoto?: HagilightToggleOptions;
|
|
66
|
+
/** Body-image baseline (`loading`, `decoding`, marker class) for Markdown and MDX. Defaults to enabled. */
|
|
67
|
+
contentImages?: HagilightToggleOptions;
|
|
66
68
|
/** Header and footer link customization passed to `resolveSiteLinks`. */
|
|
67
69
|
links?: SiteLinksOptions;
|
|
68
70
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import { resolveFaviconHeadEntry } from '@hagicode/hagilight-core/favicon';
|
|
4
|
+
import { checkContentImageRegistration, registerContentImages } from '@hagicode/hagilight-core/content-images';
|
|
4
5
|
import { resolveRssLocales } from '@hagicode/hagilight-core/rss';
|
|
5
6
|
import { RSS_OWNER, registerStarlightRssOwner, } from '@hagicode/hagilight-core/rss-ownership';
|
|
6
7
|
import { isValidSeoImageReference, resolveSeoImageUrl } from '@hagicode/hagilight-core/seo';
|
|
@@ -199,7 +200,7 @@ function resolveDefaultSeoLocale(defaultLocale, locales) {
|
|
|
199
200
|
}
|
|
200
201
|
return found.route;
|
|
201
202
|
}
|
|
202
|
-
function createConfiguredIntegration(instanceId, serializedOptions, rssConfig, rssLocaleFeedUrls, componentIds, getConfiguredRssFeed, generateRss, unregisterRssOwner) {
|
|
203
|
+
function createConfiguredIntegration(instanceId, serializedOptions, rssConfig, rssLocaleFeedUrls, componentIds, getConfiguredRssFeed, generateRss, unregisterRssOwner, contentImagesEnabled) {
|
|
203
204
|
const optionsId = `virtual:hagilight-starlight/${instanceId}/options`;
|
|
204
205
|
const rssConfigId = 'virtual:hagilight-starlight/rss-config';
|
|
205
206
|
const headerPath = componentIds.header ? packageFile('Header.astro') : undefined;
|
|
@@ -303,7 +304,8 @@ const isNotFound = /(?:^|\\/)404(?:\\.html)?\\/?$/u.test(Astro.url.pathname);
|
|
|
303
304
|
name: `@hagicode/hagilight-starlight:${instanceId}`,
|
|
304
305
|
[RSS_OWNER]: { package: 'starlight', enabled: generateRss },
|
|
305
306
|
hooks: {
|
|
306
|
-
'astro:config:setup'({ injectRoute, updateConfig }) {
|
|
307
|
+
'astro:config:setup'({ config, injectRoute, updateConfig, logger }) {
|
|
308
|
+
registerContentImages({ config, logger, enabled: contentImagesEnabled });
|
|
307
309
|
if (generateRss) {
|
|
308
310
|
injectRoute({
|
|
309
311
|
pattern: '/rss.xml',
|
|
@@ -320,6 +322,7 @@ const isNotFound = /(?:^|\\/)404(?:\\.html)?\\/?$/u.test(Astro.url.pathname);
|
|
|
320
322
|
},
|
|
321
323
|
'astro:config:done'({ config, logger }) {
|
|
322
324
|
unregisterRssOwner();
|
|
325
|
+
checkContentImageRegistration({ config, logger, enabled: contentImagesEnabled });
|
|
323
326
|
if (config.image?.service?.entrypoint === NOOP_IMAGE_SERVICE) {
|
|
324
327
|
logger.warn(NOOP_IMAGE_SERVICE_WARNING);
|
|
325
328
|
}
|
|
@@ -363,6 +366,8 @@ export default function hagilight(options = {}) {
|
|
|
363
366
|
});
|
|
364
367
|
const promoto = optionalRecord(input.promoto, 'promoto');
|
|
365
368
|
const promotoEnabled = optionalBoolean(promoto, 'enabled', 'promoto enabled') !== false;
|
|
369
|
+
const contentImages = optionalRecord(input.contentImages, 'contentImages');
|
|
370
|
+
const contentImagesEnabled = optionalBoolean(contentImages, 'enabled', 'contentImages enabled') !== false;
|
|
366
371
|
const instanceId = randomUUID();
|
|
367
372
|
const componentIds = {
|
|
368
373
|
header: headerEnabled
|
|
@@ -471,7 +476,7 @@ export default function hagilight(options = {}) {
|
|
|
471
476
|
new URL(`rss.${filename}.xml`, baseUrl).toString(),
|
|
472
477
|
]))
|
|
473
478
|
: {};
|
|
474
|
-
addIntegration(createConfiguredIntegration(instanceId, serializedOptions, { options: rssOptions, locales: rssLocales }, rssLocaleFeedUrls, componentIds, () => getRssFeedUrl(config) ?? rssFeedUrl, generateRss, unregisterRssOwner));
|
|
479
|
+
addIntegration(createConfiguredIntegration(instanceId, serializedOptions, { options: rssOptions, locales: rssLocales }, rssLocaleFeedUrls, componentIds, () => getRssFeedUrl(config) ?? rssFeedUrl, generateRss, unregisterRssOwner, contentImagesEnabled));
|
|
475
480
|
updateConfig({
|
|
476
481
|
...(config.logo === undefined ? { logo: { src: defaultLogo, alt: 'HagiCode' } } : {}),
|
|
477
482
|
customCss: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hagicode/hagilight-starlight",
|
|
3
|
-
"version": "0.8.1-dev.
|
|
3
|
+
"version": "0.8.1-dev.92.1.85649f3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Starlight plugin and components for HagiCode documentation",
|
|
6
6
|
"repository": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"assets/showcase/*"
|
|
54
54
|
],
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@hagicode/hagilight-core": "0.8.1-dev.
|
|
56
|
+
"@hagicode/hagilight-core": "0.8.1-dev.92.1.85649f3"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@astrojs/starlight": "^0.42.4",
|