for-humanity 0.1.0 → 0.2.0

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.
@@ -2,6 +2,7 @@ import {z} from "zod";
2
2
  import {copy_error_navigation_clash, copy_site_title_default} from "@/constant/copy";
3
3
  import {site_navigation_default} from "@/constant/site";
4
4
  import {status_default_phrases, status_kind} from "@/constant/status";
5
+ import {groupPathSchema} from "@/type/group-path";
5
6
 
6
7
  /**
7
8
  * for-humanity.config.mjs 설정 스키마
@@ -17,12 +18,12 @@ export const siteConfigSchema = z.object({
17
18
  */
18
19
  description: z.string().optional(),
19
20
  /**
20
- * 탐색 묶음의 읽는 순서 · 미지정 묶음은 뒤에서 이름순
21
+ * 탐색 묶음 경로의 읽는 순서 · 미지정 형제 묶음은 뒤에서 이름순
21
22
  */
22
23
  navigation: z
23
- .array(z.string().trim().min(1))
24
- .refine((groups) => new Set(groups).size === groups.length, copy_error_navigation_clash)
25
- .default([...site_navigation_default]),
24
+ .array(groupPathSchema)
25
+ .refine((groups) => new Set(groups.map((path) => JSON.stringify(path))).size === groups.length, copy_error_navigation_clash)
26
+ .default(site_navigation_default.map((name) => [name])),
26
27
  /**
27
28
  * 본문에서 상태 표지로 표시할 문구
28
29
  */
@@ -1,18 +0,0 @@
1
- import {locale_doc_group, locale_doc_name} from "@/constant/locale";
2
- import type {Doc} from "@/type/doc";
3
- import type {SiteConfig} from "@/type/site-config";
4
-
5
- /**
6
- * 사이드바의 읽는 순서 · 설정 밖 묶음은 뒤에서 이름순
7
- * 같은 문서 이름·순서도 파일 id로 구분해 탐색 순서를 고정
8
- */
9
- export const toDocGroups = (options: {docs: readonly Doc[]; navigation: SiteConfig["navigation"]}) => {
10
- const positions = new Map(options.navigation.map((name, index) => [name, index]));
11
-
12
- return [...Map.groupBy(options.docs, (doc) => doc.data.group)]
13
- .toSorted((a, b) => (positions.get(a[0]) ?? options.navigation.length) - (positions.get(b[0]) ?? options.navigation.length) || a[0].localeCompare(b[0], locale_doc_group))
14
- .map(([name, docs]) => ({
15
- name,
16
- docs: docs.toSorted((a, b) => a.data.order - b.data.order || a.data.name.localeCompare(b.data.name, locale_doc_name) || a.id.localeCompare(b.id, locale_doc_name)),
17
- }));
18
- };