@anglefeint/astro-theme 0.1.17 → 0.1.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anglefeint/astro-theme",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "type": "module",
5
5
  "description": "Anglefeint core theme package for Astro",
6
6
  "keywords": [
@@ -26,6 +26,7 @@
26
26
  "src/scripts",
27
27
  "src/i18n",
28
28
  "src/styles",
29
+ "src/utils",
29
30
  "src/assets/theme",
30
31
  "src/cli-new-post.mjs",
31
32
  "src/cli-new-page.mjs"
@@ -42,6 +43,8 @@
42
43
  "./i18n/*": "./src/i18n/*",
43
44
  "./styles/*": "./src/styles/*",
44
45
  "./assets/*": "./src/assets/*",
46
+ "./utils/merge": "./src/utils/merge.ts",
47
+ "./utils/*": "./src/utils/*",
45
48
  "./content-schema": "./src/content-schema.ts",
46
49
  "./consts": "./src/consts.ts"
47
50
  },
@@ -5,7 +5,9 @@ import { SUPPORTED_LOCALES } from './i18n/locales.mjs';
5
5
  import {
6
6
  buildNewPostTemplate,
7
7
  loadDefaultCovers,
8
+ parseNewPostArgs,
8
9
  pickDefaultCoverBySlug,
10
+ resolveLocales,
9
11
  usageNewPost,
10
12
  validatePostSlug,
11
13
  } from './scaffold/new-post.mjs';
@@ -23,7 +25,7 @@ async function exists(filePath) {
23
25
  }
24
26
 
25
27
  async function main() {
26
- const slug = process.argv[2];
28
+ const { slug, locales: cliLocales } = parseNewPostArgs(process.argv);
27
29
  if (!slug) {
28
30
  console.error(usageNewPost());
29
31
  process.exit(1);
@@ -36,10 +38,15 @@ async function main() {
36
38
 
37
39
  const pubDate = new Date().toISOString().slice(0, 10);
38
40
  const defaultCovers = await loadDefaultCovers(DEFAULT_COVERS_ROOT);
41
+ const locales = resolveLocales({
42
+ cliLocales,
43
+ envLocales: process.env.ANGLEFEINT_LOCALES ?? '',
44
+ defaultLocales: SUPPORTED_LOCALES,
45
+ });
39
46
  const created = [];
40
47
  const skipped = [];
41
48
 
42
- for (const locale of SUPPORTED_LOCALES) {
49
+ for (const locale of locales) {
43
50
  const localeDir = path.join(CONTENT_ROOT, locale);
44
51
  const filePath = path.join(localeDir, `${slug}.md`);
45
52
  await mkdir(localeDir, { recursive: true });
@@ -8,4 +8,8 @@ export const THEME = {
8
8
  HOME_LATEST_COUNT: 3,
9
9
  /** Whether to enable the About page (disable to hide from nav/routes if needed) */
10
10
  ENABLE_ABOUT_PAGE: true,
11
+ /** Optional visual effects switches */
12
+ EFFECTS: {
13
+ ENABLE_RED_QUEEN: true,
14
+ },
11
15
  } as const;
@@ -7,6 +7,7 @@ import FormattedDate from '../components/FormattedDate.astro';
7
7
  import AiShell from './shells/AiShell.astro';
8
8
  import blogPostCssUrl from '../styles/blog-post.css?url';
9
9
  import { SITE_AUTHOR } from '@anglefeint/site-config/site';
10
+ import { THEME } from '@anglefeint/site-config/theme';
10
11
  import { DEFAULT_LOCALE, type Locale, isLocale, localePath, blogIdToSlugAnyLocale } from '@anglefeint/site-i18n/config';
11
12
  import { getMessages } from '@anglefeint/site-i18n/messages';
12
13
 
@@ -49,6 +50,7 @@ const hasSystemMeta = Boolean(aiModel || aiMode || aiState);
49
50
  const hasResponseMeta = aiLatencyMs !== undefined || aiConfidence !== undefined;
50
51
  const hasStats = aiModel || wordCount !== undefined || tokenCount !== undefined;
51
52
  const confidenceText = aiConfidence !== undefined ? aiConfidence.toFixed(2) : undefined;
53
+ const enableRedQueen = THEME.EFFECTS.ENABLE_RED_QUEEN;
52
54
  ---
53
55
 
54
56
  <AiShell
@@ -79,11 +81,13 @@ const confidenceText = aiConfidence !== undefined ? aiConfidence.toFixed(2) : un
79
81
  </div>
80
82
  <canvas class="ai-network-canvas" aria-hidden="true"></canvas>
81
83
  </div>
82
- <aside class="rq-tv rq-tv-collapsed">
83
- <div class="rq-tv-stage" data-rq-src={themeRedqueen1.src} data-rq-src2={themeRedqueen2.src}></div>
84
- <div class="rq-tv-badge">monitor feed<span class="rq-tv-dot"></span></div>
85
- <button type="button" class="rq-tv-toggle" aria-label="Replay monitor feed" aria-expanded="false">▶</button>
86
- </aside>
84
+ {enableRedQueen && (
85
+ <aside class="rq-tv rq-tv-collapsed">
86
+ <div class="rq-tv-stage" data-rq-src={themeRedqueen1.src} data-rq-src2={themeRedqueen2.src}></div>
87
+ <div class="rq-tv-badge">monitor feed<span class="rq-tv-dot"></span></div>
88
+ <button type="button" class="rq-tv-toggle" aria-label="Replay monitor feed" aria-expanded="false">▶</button>
89
+ </aside>
90
+ )}
87
91
  <div class="ai-read-progress" aria-hidden="true"></div>
88
92
  <button type="button" class="ai-back-to-top" aria-label="Back to top" title="Back to top">↑</button>
89
93
  <div class="ai-stage-toast" aria-live="polite" aria-atomic="true"></div>
@@ -17,6 +17,8 @@ export function initBlogpostEffects() {
17
17
  initReadProgressAndBackToTop(prefersReducedMotion);
18
18
  initNetworkCanvas(prefersReducedMotion);
19
19
  initHeroCanvas(prefersReducedMotion);
20
- initRedQueenTv(prefersReducedMotion);
20
+ if (document.querySelector('.rq-tv-stage')) {
21
+ initRedQueenTv(prefersReducedMotion);
22
+ }
21
23
  initPostInteractions(prefersReducedMotion);
22
24
  }
@@ -0,0 +1,31 @@
1
+ export type DeepPartial<T> = {
2
+ [K in keyof T]?: T[K] extends Array<infer U>
3
+ ? Array<DeepPartial<U>>
4
+ : T[K] extends object
5
+ ? DeepPartial<T[K]>
6
+ : T[K];
7
+ };
8
+
9
+ export function isPlainObject(value: unknown): value is Record<string, unknown> {
10
+ return Object.prototype.toString.call(value) === '[object Object]';
11
+ }
12
+
13
+ export function deepMerge<T>(base: T, override: DeepPartial<T>): T {
14
+ if (!isPlainObject(base) || !isPlainObject(override)) return (override as T) ?? base;
15
+
16
+ const result: Record<string, unknown> = { ...(base as Record<string, unknown>) };
17
+ for (const [key, value] of Object.entries(override)) {
18
+ if (value === undefined) continue;
19
+ const existing = result[key];
20
+ if (Array.isArray(value)) {
21
+ result[key] = value;
22
+ continue;
23
+ }
24
+ if (isPlainObject(existing) && isPlainObject(value)) {
25
+ result[key] = deepMerge(existing, value);
26
+ continue;
27
+ }
28
+ result[key] = value;
29
+ }
30
+ return result as T;
31
+ }