@hagicode/hagilight 0.8.1-dev.87.1.57ea49d → 0.8.1-dev.88.1.80b3713
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 +13 -0
- package/dist/integration.d.ts +11 -1
- package/dist/integration.js +14 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -34,4 +34,17 @@ time from this package's own manifest, not from Astro. Existing
|
|
|
34
34
|
feature-package attribution; switch that import to `@hagicode/hagilight/Footer`
|
|
35
35
|
to opt in while keeping the same `locale` and `links` props.
|
|
36
36
|
|
|
37
|
+
## Body images
|
|
38
|
+
|
|
39
|
+
`hagilight()` registers the content-image plugin from `@hagicode/hagilight-core/content-images`. Markdown and MDX body images then get `loading="lazy"`, `decoding="async"`, and the class `hagilight-content-image`, with the author's values kept. This registration does not depend on `enabled`, so `hagilight({ enabled: false })` still registers the plugin.
|
|
40
|
+
|
|
41
|
+
To opt out, pass either form:
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
hagilight({ contentImages: false });
|
|
45
|
+
hagilight({ contentImages: { enabled: false } });
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Sites that do not use this integration can import the plugin from `@hagicode/hagilight-core` directly; its README describes the options and processor setup.
|
|
49
|
+
|
|
37
50
|
See the [repository documentation](https://github.com/HagiCode-org/hagilight#readme) for RSS configuration, feed callback types, and integration behavior.
|
package/dist/integration.d.ts
CHANGED
|
@@ -15,6 +15,16 @@ export interface HagilightOptions {
|
|
|
15
15
|
* `RssFeedCallback`. A built-in empty feed is used when omitted.
|
|
16
16
|
*/
|
|
17
17
|
rss?: boolean | HagilightRssOptions;
|
|
18
|
+
/**
|
|
19
|
+
* Apply the body-image baseline (`loading`, `decoding`, marker class) to Markdown
|
|
20
|
+
* and MDX images. Defaults to `true`; `false` or `{ enabled: false }` opts out.
|
|
21
|
+
* Independent of `enabled`, which controls only sitemap and robots.
|
|
22
|
+
*/
|
|
23
|
+
contentImages?: boolean | HagilightContentImagesOptions;
|
|
24
|
+
}
|
|
25
|
+
export interface HagilightContentImagesOptions {
|
|
26
|
+
/** Defaults to `true`. */
|
|
27
|
+
enabled?: boolean;
|
|
18
28
|
}
|
|
19
29
|
export interface HagilightRssOptions {
|
|
20
30
|
/** Starlight-shaped locale map, for example `{ root: { lang: 'en-US' }, 'zh-CN': { lang: 'zh-CN' } }`. Derived from Astro `i18n` when omitted. */
|
|
@@ -29,6 +39,6 @@ export type HagilightFaviconOptions = FaviconOptions;
|
|
|
29
39
|
* owns sitemap generation, a consumer-owned robots page or public file takes
|
|
30
40
|
* precedence, and an enabled Starlight Hagilight integration owns RSS feeds.
|
|
31
41
|
*/
|
|
32
|
-
export declare function hagilight({ enabled, rss }?: HagilightOptions): AstroIntegration;
|
|
42
|
+
export declare function hagilight({ enabled, rss, contentImages }?: HagilightOptions): AstroIntegration;
|
|
33
43
|
/** Inject the bundled HagiCode favicon unless the site head already declares an icon. */
|
|
34
44
|
export declare function hagilightFavicon(options?: HagilightFaviconOptions): AstroIntegration;
|
package/dist/integration.js
CHANGED
|
@@ -2,6 +2,7 @@ import { existsSync, readdirSync, statSync } from 'node:fs';
|
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import { extname, isAbsolute, resolve, win32 } from 'node:path';
|
|
4
4
|
import sitemap from '@astrojs/sitemap';
|
|
5
|
+
import { checkContentImageRegistration, registerContentImages } from '@hagicode/hagilight-core/content-images';
|
|
5
6
|
import { resolveFaviconHeadEntry } from '@hagicode/hagilight-core/favicon';
|
|
6
7
|
import { resolveRssLocales } from '@hagicode/hagilight-core/rss';
|
|
7
8
|
import { resolvePlainAstroRssOwner } from '@hagicode/hagilight-core/rss-ownership';
|
|
@@ -47,10 +48,17 @@ const BUILTIN_RSS_FEED_SOURCE = BUILTIN_RSS_FEED.toString();
|
|
|
47
48
|
* owns sitemap generation, a consumer-owned robots page or public file takes
|
|
48
49
|
* precedence, and an enabled Starlight Hagilight integration owns RSS feeds.
|
|
49
50
|
*/
|
|
50
|
-
export function hagilight({ enabled = true, rss } = {}) {
|
|
51
|
+
export function hagilight({ enabled = true, rss, contentImages } = {}) {
|
|
51
52
|
if (typeof enabled !== 'boolean') {
|
|
52
53
|
throw new TypeError('Hagilight sitemap and robots enabled option must be a boolean.');
|
|
53
54
|
}
|
|
55
|
+
if (contentImages !== undefined && typeof contentImages !== 'boolean' && !isRecord(contentImages)) {
|
|
56
|
+
throw new TypeError('Hagilight content images option must be a boolean or an options object.');
|
|
57
|
+
}
|
|
58
|
+
if (isRecord(contentImages) && contentImages.enabled !== undefined && typeof contentImages.enabled !== 'boolean') {
|
|
59
|
+
throw new TypeError('Hagilight content images enabled option must be a boolean.');
|
|
60
|
+
}
|
|
61
|
+
const contentImagesEnabled = typeof contentImages === 'boolean' ? contentImages : contentImages?.enabled !== false;
|
|
54
62
|
if (rss !== undefined && typeof rss !== 'boolean' && !isRecord(rss)) {
|
|
55
63
|
throw new TypeError('Hagilight RSS option must be a boolean or an options object.');
|
|
56
64
|
}
|
|
@@ -65,7 +73,8 @@ export function hagilight({ enabled = true, rss } = {}) {
|
|
|
65
73
|
return {
|
|
66
74
|
name: '@hagicode/hagilight:discovery',
|
|
67
75
|
hooks: {
|
|
68
|
-
'astro:config:setup'({ config, injectRoute, addMiddleware, updateConfig }) {
|
|
76
|
+
'astro:config:setup'({ config, injectRoute, addMiddleware, updateConfig, logger }) {
|
|
77
|
+
registerContentImages({ config, logger, enabled: contentImagesEnabled });
|
|
69
78
|
if (!enabled)
|
|
70
79
|
return;
|
|
71
80
|
resolveDiscoverySite(config.site);
|
|
@@ -114,6 +123,9 @@ export function hagilight({ enabled = true, rss } = {}) {
|
|
|
114
123
|
},
|
|
115
124
|
});
|
|
116
125
|
},
|
|
126
|
+
'astro:config:done'({ config, logger }) {
|
|
127
|
+
checkContentImageRegistration({ config, logger, enabled: contentImagesEnabled });
|
|
128
|
+
},
|
|
117
129
|
},
|
|
118
130
|
};
|
|
119
131
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hagicode/hagilight",
|
|
3
|
-
"version": "0.8.1-dev.
|
|
3
|
+
"version": "0.8.1-dev.88.1.80b3713",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Astro integrations and components for HagiCode sites",
|
|
6
6
|
"repository": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@astrojs/sitemap": "^3.7.4",
|
|
43
|
-
"@hagicode/hagilight-core": "0.8.1-dev.
|
|
43
|
+
"@hagicode/hagilight-core": "0.8.1-dev.88.1.80b3713"
|
|
44
44
|
},
|
|
45
45
|
"keywords": [
|
|
46
46
|
"astro-component",
|