@roottale/cms-core 0.53.1 → 0.55.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.
- package/CHANGELOG.md +9 -0
- package/dist/index.cjs +113 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +57 -2
- package/dist/index.d.ts +57 -2
- package/dist/index.js +108 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -83,7 +83,8 @@ declare function bindingSrcValue(value: unknown): string | undefined;
|
|
|
83
83
|
*
|
|
84
84
|
* 설계(codex consult `019ef577` 반영):
|
|
85
85
|
* - **활성화 = `collections.length > 0`.** 빈 배열·미전달 = 레거시 단일 /blog.
|
|
86
|
-
* - `RouteCollection` 은 **라우팅 최소셋**만(key/basePath/categories/feed/archives
|
|
86
|
+
* - `RouteCollection` 은 **라우팅 최소셋**만(key/basePath/categories/feed/archives와
|
|
87
|
+
* 경로 정책) 가진다.
|
|
87
88
|
* label/layout/icon 등 표시·작성 메타는 templates `CollectionSchema` 에 둔다.
|
|
88
89
|
*/
|
|
89
90
|
/** 콘텐츠 스트림 1개 — sitemap/feed/아카이브 파생의 라우팅 단위. */
|
|
@@ -118,6 +119,20 @@ interface RouteCollection {
|
|
|
118
119
|
* — 소속과 상세 URL 존재 여부는 별개(M4 원칙 연장).
|
|
119
120
|
*/
|
|
120
121
|
readonly detail?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* 글 상세 주소 형식. `flat`(기본) = `${basePath}/{postSlug}`,
|
|
124
|
+
* `category` = `${basePath}/{categorySlug}/{postSlug}`.
|
|
125
|
+
* category 모드는 URL을 하나로 결정해야 하므로 `categoryCardinality: "exactly-one"`
|
|
126
|
+
* 과 함께 쓴다.
|
|
127
|
+
*/
|
|
128
|
+
readonly detailPath?: "flat" | "category";
|
|
129
|
+
/**
|
|
130
|
+
* 카테고리 허브 주소 형식. `namespaced`(기본) =
|
|
131
|
+
* `${basePath}/categories/{slug}`, `direct` = `${basePath}/{slug}`.
|
|
132
|
+
*/
|
|
133
|
+
readonly categoryPath?: "namespaced" | "direct";
|
|
134
|
+
/** 글에 허용하는 category term 개수. 기본 `multiple`(기존 동작). */
|
|
135
|
+
readonly categoryCardinality?: "multiple" | "exactly-one";
|
|
121
136
|
}
|
|
122
137
|
/** resolve 입력 — 글의 구조적 최소 형태(cms-client `CmsPostContent` 와 구조 호환). */
|
|
123
138
|
interface RoutablePost {
|
|
@@ -149,6 +164,14 @@ declare function resolvePostCollection(post: RoutablePost, collections: readonly
|
|
|
149
164
|
* (주소 없는 유형)이면 null. slug 는 percent-encoding (한글 slug 안전).
|
|
150
165
|
*/
|
|
151
166
|
declare function resolvePostUrl(siteUrl: string, post: RoutablePost, collections: readonly RouteCollection[]): string | null;
|
|
167
|
+
/**
|
|
168
|
+
* category 기반 상세 주소에 사용할 단일 category slug. collection 에 연결된
|
|
169
|
+
* category만 세고 정확히 1개일 때만 반환한다. 0개·2개 이상이면 정규 URL을
|
|
170
|
+
* 임의 선택하지 않고 null 로 닫는다.
|
|
171
|
+
*/
|
|
172
|
+
declare function resolvePostCategorySlug(post: RoutablePost, collection: RouteCollection): string | null;
|
|
173
|
+
/** 카테고리 허브 경로. archives 가 꺼졌거나 주소가 없으면 null. */
|
|
174
|
+
declare function resolveCategoryPath(collection: RouteCollection, categorySlug: string): string | null;
|
|
152
175
|
/**
|
|
153
176
|
* 글의 *경로*(siteUrl 없는 basePath-상대) — 예: "/blog/hello". 소속 스트림이
|
|
154
177
|
* 없거나, `detail: false`(목록 전용 유형) 이거나, `basePath` 가 빈 문자열
|
|
@@ -178,6 +201,38 @@ declare function postsNotInAnyCollection<T extends RoutablePost>(posts: readonly
|
|
|
178
201
|
*/
|
|
179
202
|
declare function validateCollections(collections: readonly RouteCollection[]): string[];
|
|
180
203
|
|
|
204
|
+
/**
|
|
205
|
+
* 콘텐츠 모델의 계층형 분류 주소 계산기.
|
|
206
|
+
*
|
|
207
|
+
* FAQ·도움말·문서처럼 하나의 모델이 여러 단계 분류 허브를 가지는 경우에 쓴다.
|
|
208
|
+
* 저장소나 프레임워크를 모르며, 공개 API와 ROOT-ADMIN이 같은 계산을 재사용한다.
|
|
209
|
+
*/
|
|
210
|
+
interface CategoryTreePresentation {
|
|
211
|
+
readonly basePath: string;
|
|
212
|
+
readonly categoryDepth: number;
|
|
213
|
+
}
|
|
214
|
+
interface CategoryTreeTerm {
|
|
215
|
+
readonly id: string;
|
|
216
|
+
readonly slug: string;
|
|
217
|
+
readonly parentId?: string | null;
|
|
218
|
+
}
|
|
219
|
+
interface CategoryTreeEntry {
|
|
220
|
+
readonly slug: string;
|
|
221
|
+
readonly terms: ReadonlyArray<{
|
|
222
|
+
readonly id: string;
|
|
223
|
+
readonly taxonomy: string;
|
|
224
|
+
}>;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* 선택한 말단 분류부터 루트까지의 사슬을 루트→말단 순서로 돌려준다.
|
|
228
|
+
* 끊긴 부모·순환·중복 id·깊이 불일치·말단이 아닌 선택은 null로 닫는다.
|
|
229
|
+
*/
|
|
230
|
+
declare function resolveCategoryTreeChain(presentation: CategoryTreePresentation, leafId: string, terms: readonly CategoryTreeTerm[]): CategoryTreeTerm[] | null;
|
|
231
|
+
/** 루트부터 선택 분류까지 모든 허브 주소. */
|
|
232
|
+
declare function resolveCategoryTreeHubPaths(presentation: CategoryTreePresentation, termId: string, terms: readonly CategoryTreeTerm[]): string[] | null;
|
|
233
|
+
/** 계층형 분류 모델 항목의 정규 상세 주소. */
|
|
234
|
+
declare function resolveCategoryTreeEntryPath(presentation: CategoryTreePresentation, entry: CategoryTreeEntry, terms: readonly CategoryTreeTerm[]): string | null;
|
|
235
|
+
|
|
181
236
|
interface ClientHydrationSpec {
|
|
182
237
|
hydration?: "visible" | "idle" | "load" | "media" | "only";
|
|
183
238
|
module?: string;
|
|
@@ -316,4 +371,4 @@ declare function injectStableIdsTree(blocks: readonly (Omit<Block, "_id"> & {
|
|
|
316
371
|
_id?: string;
|
|
317
372
|
})[]): Block[];
|
|
318
373
|
|
|
319
|
-
export { BLOCK_NAME_PATTERN, type BindingResolver, type Block, type BlockBinding, type BlockDefinition, type BlockRegistry, type ClientHydrationSpec, type EmbedProvider, FIELD_BINDING_SOURCE, FIELD_BINDING_SOURCE_ALIAS, type FaqEntry, IMAGE_ALT_MAX_LENGTH, type NormalizedEmbed, PHASE_1_CORE_BLOCKS, PHASE_1_CSP, type Phase1CoreBlockName, type PreviewTokenPayload, type RoutablePost, type RouteCollection, applyBlockBindings, bindingSrcValue, bindingTextValue, blockSchema, boundFieldValue, chainResolvers, createFieldBindingResolver, ensureImportedHtmlDocumentRoots, ensureStableIds, extractFaqEntries, faqPageJsonLd, htmlToPlainText, injectStableIdsTree, isAllowedEmbedSrc, isAllowedMapEmbedSrc, isInCollectionMode, isValidBlock, issuePreviewToken, normalizeEmbed, normalizeImageAlt, parseBlock, postsForCollection, postsInAnyCollection, postsNotInAnyCollection, resolvePostCollection, resolvePostPath, resolvePostUrl, sanitizeHtml, sanitizeImportedCss, sanitizeImportedHtml, scopeImportedCss, serializeBlock, validateCollections, verifyPreviewToken };
|
|
374
|
+
export { BLOCK_NAME_PATTERN, type BindingResolver, type Block, type BlockBinding, type BlockDefinition, type BlockRegistry, type CategoryTreeEntry, type CategoryTreePresentation, type CategoryTreeTerm, type ClientHydrationSpec, type EmbedProvider, FIELD_BINDING_SOURCE, FIELD_BINDING_SOURCE_ALIAS, type FaqEntry, IMAGE_ALT_MAX_LENGTH, type NormalizedEmbed, PHASE_1_CORE_BLOCKS, PHASE_1_CSP, type Phase1CoreBlockName, type PreviewTokenPayload, type RoutablePost, type RouteCollection, applyBlockBindings, bindingSrcValue, bindingTextValue, blockSchema, boundFieldValue, chainResolvers, createFieldBindingResolver, ensureImportedHtmlDocumentRoots, ensureStableIds, extractFaqEntries, faqPageJsonLd, htmlToPlainText, injectStableIdsTree, isAllowedEmbedSrc, isAllowedMapEmbedSrc, isInCollectionMode, isValidBlock, issuePreviewToken, normalizeEmbed, normalizeImageAlt, parseBlock, postsForCollection, postsInAnyCollection, postsNotInAnyCollection, resolveCategoryPath, resolveCategoryTreeChain, resolveCategoryTreeEntryPath, resolveCategoryTreeHubPaths, resolvePostCategorySlug, resolvePostCollection, resolvePostPath, resolvePostUrl, sanitizeHtml, sanitizeImportedCss, sanitizeImportedHtml, scopeImportedCss, serializeBlock, validateCollections, verifyPreviewToken };
|
package/dist/index.d.ts
CHANGED
|
@@ -83,7 +83,8 @@ declare function bindingSrcValue(value: unknown): string | undefined;
|
|
|
83
83
|
*
|
|
84
84
|
* 설계(codex consult `019ef577` 반영):
|
|
85
85
|
* - **활성화 = `collections.length > 0`.** 빈 배열·미전달 = 레거시 단일 /blog.
|
|
86
|
-
* - `RouteCollection` 은 **라우팅 최소셋**만(key/basePath/categories/feed/archives
|
|
86
|
+
* - `RouteCollection` 은 **라우팅 최소셋**만(key/basePath/categories/feed/archives와
|
|
87
|
+
* 경로 정책) 가진다.
|
|
87
88
|
* label/layout/icon 등 표시·작성 메타는 templates `CollectionSchema` 에 둔다.
|
|
88
89
|
*/
|
|
89
90
|
/** 콘텐츠 스트림 1개 — sitemap/feed/아카이브 파생의 라우팅 단위. */
|
|
@@ -118,6 +119,20 @@ interface RouteCollection {
|
|
|
118
119
|
* — 소속과 상세 URL 존재 여부는 별개(M4 원칙 연장).
|
|
119
120
|
*/
|
|
120
121
|
readonly detail?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* 글 상세 주소 형식. `flat`(기본) = `${basePath}/{postSlug}`,
|
|
124
|
+
* `category` = `${basePath}/{categorySlug}/{postSlug}`.
|
|
125
|
+
* category 모드는 URL을 하나로 결정해야 하므로 `categoryCardinality: "exactly-one"`
|
|
126
|
+
* 과 함께 쓴다.
|
|
127
|
+
*/
|
|
128
|
+
readonly detailPath?: "flat" | "category";
|
|
129
|
+
/**
|
|
130
|
+
* 카테고리 허브 주소 형식. `namespaced`(기본) =
|
|
131
|
+
* `${basePath}/categories/{slug}`, `direct` = `${basePath}/{slug}`.
|
|
132
|
+
*/
|
|
133
|
+
readonly categoryPath?: "namespaced" | "direct";
|
|
134
|
+
/** 글에 허용하는 category term 개수. 기본 `multiple`(기존 동작). */
|
|
135
|
+
readonly categoryCardinality?: "multiple" | "exactly-one";
|
|
121
136
|
}
|
|
122
137
|
/** resolve 입력 — 글의 구조적 최소 형태(cms-client `CmsPostContent` 와 구조 호환). */
|
|
123
138
|
interface RoutablePost {
|
|
@@ -149,6 +164,14 @@ declare function resolvePostCollection(post: RoutablePost, collections: readonly
|
|
|
149
164
|
* (주소 없는 유형)이면 null. slug 는 percent-encoding (한글 slug 안전).
|
|
150
165
|
*/
|
|
151
166
|
declare function resolvePostUrl(siteUrl: string, post: RoutablePost, collections: readonly RouteCollection[]): string | null;
|
|
167
|
+
/**
|
|
168
|
+
* category 기반 상세 주소에 사용할 단일 category slug. collection 에 연결된
|
|
169
|
+
* category만 세고 정확히 1개일 때만 반환한다. 0개·2개 이상이면 정규 URL을
|
|
170
|
+
* 임의 선택하지 않고 null 로 닫는다.
|
|
171
|
+
*/
|
|
172
|
+
declare function resolvePostCategorySlug(post: RoutablePost, collection: RouteCollection): string | null;
|
|
173
|
+
/** 카테고리 허브 경로. archives 가 꺼졌거나 주소가 없으면 null. */
|
|
174
|
+
declare function resolveCategoryPath(collection: RouteCollection, categorySlug: string): string | null;
|
|
152
175
|
/**
|
|
153
176
|
* 글의 *경로*(siteUrl 없는 basePath-상대) — 예: "/blog/hello". 소속 스트림이
|
|
154
177
|
* 없거나, `detail: false`(목록 전용 유형) 이거나, `basePath` 가 빈 문자열
|
|
@@ -178,6 +201,38 @@ declare function postsNotInAnyCollection<T extends RoutablePost>(posts: readonly
|
|
|
178
201
|
*/
|
|
179
202
|
declare function validateCollections(collections: readonly RouteCollection[]): string[];
|
|
180
203
|
|
|
204
|
+
/**
|
|
205
|
+
* 콘텐츠 모델의 계층형 분류 주소 계산기.
|
|
206
|
+
*
|
|
207
|
+
* FAQ·도움말·문서처럼 하나의 모델이 여러 단계 분류 허브를 가지는 경우에 쓴다.
|
|
208
|
+
* 저장소나 프레임워크를 모르며, 공개 API와 ROOT-ADMIN이 같은 계산을 재사용한다.
|
|
209
|
+
*/
|
|
210
|
+
interface CategoryTreePresentation {
|
|
211
|
+
readonly basePath: string;
|
|
212
|
+
readonly categoryDepth: number;
|
|
213
|
+
}
|
|
214
|
+
interface CategoryTreeTerm {
|
|
215
|
+
readonly id: string;
|
|
216
|
+
readonly slug: string;
|
|
217
|
+
readonly parentId?: string | null;
|
|
218
|
+
}
|
|
219
|
+
interface CategoryTreeEntry {
|
|
220
|
+
readonly slug: string;
|
|
221
|
+
readonly terms: ReadonlyArray<{
|
|
222
|
+
readonly id: string;
|
|
223
|
+
readonly taxonomy: string;
|
|
224
|
+
}>;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* 선택한 말단 분류부터 루트까지의 사슬을 루트→말단 순서로 돌려준다.
|
|
228
|
+
* 끊긴 부모·순환·중복 id·깊이 불일치·말단이 아닌 선택은 null로 닫는다.
|
|
229
|
+
*/
|
|
230
|
+
declare function resolveCategoryTreeChain(presentation: CategoryTreePresentation, leafId: string, terms: readonly CategoryTreeTerm[]): CategoryTreeTerm[] | null;
|
|
231
|
+
/** 루트부터 선택 분류까지 모든 허브 주소. */
|
|
232
|
+
declare function resolveCategoryTreeHubPaths(presentation: CategoryTreePresentation, termId: string, terms: readonly CategoryTreeTerm[]): string[] | null;
|
|
233
|
+
/** 계층형 분류 모델 항목의 정규 상세 주소. */
|
|
234
|
+
declare function resolveCategoryTreeEntryPath(presentation: CategoryTreePresentation, entry: CategoryTreeEntry, terms: readonly CategoryTreeTerm[]): string | null;
|
|
235
|
+
|
|
181
236
|
interface ClientHydrationSpec {
|
|
182
237
|
hydration?: "visible" | "idle" | "load" | "media" | "only";
|
|
183
238
|
module?: string;
|
|
@@ -316,4 +371,4 @@ declare function injectStableIdsTree(blocks: readonly (Omit<Block, "_id"> & {
|
|
|
316
371
|
_id?: string;
|
|
317
372
|
})[]): Block[];
|
|
318
373
|
|
|
319
|
-
export { BLOCK_NAME_PATTERN, type BindingResolver, type Block, type BlockBinding, type BlockDefinition, type BlockRegistry, type ClientHydrationSpec, type EmbedProvider, FIELD_BINDING_SOURCE, FIELD_BINDING_SOURCE_ALIAS, type FaqEntry, IMAGE_ALT_MAX_LENGTH, type NormalizedEmbed, PHASE_1_CORE_BLOCKS, PHASE_1_CSP, type Phase1CoreBlockName, type PreviewTokenPayload, type RoutablePost, type RouteCollection, applyBlockBindings, bindingSrcValue, bindingTextValue, blockSchema, boundFieldValue, chainResolvers, createFieldBindingResolver, ensureImportedHtmlDocumentRoots, ensureStableIds, extractFaqEntries, faqPageJsonLd, htmlToPlainText, injectStableIdsTree, isAllowedEmbedSrc, isAllowedMapEmbedSrc, isInCollectionMode, isValidBlock, issuePreviewToken, normalizeEmbed, normalizeImageAlt, parseBlock, postsForCollection, postsInAnyCollection, postsNotInAnyCollection, resolvePostCollection, resolvePostPath, resolvePostUrl, sanitizeHtml, sanitizeImportedCss, sanitizeImportedHtml, scopeImportedCss, serializeBlock, validateCollections, verifyPreviewToken };
|
|
374
|
+
export { BLOCK_NAME_PATTERN, type BindingResolver, type Block, type BlockBinding, type BlockDefinition, type BlockRegistry, type CategoryTreeEntry, type CategoryTreePresentation, type CategoryTreeTerm, type ClientHydrationSpec, type EmbedProvider, FIELD_BINDING_SOURCE, FIELD_BINDING_SOURCE_ALIAS, type FaqEntry, IMAGE_ALT_MAX_LENGTH, type NormalizedEmbed, PHASE_1_CORE_BLOCKS, PHASE_1_CSP, type Phase1CoreBlockName, type PreviewTokenPayload, type RoutablePost, type RouteCollection, applyBlockBindings, bindingSrcValue, bindingTextValue, blockSchema, boundFieldValue, chainResolvers, createFieldBindingResolver, ensureImportedHtmlDocumentRoots, ensureStableIds, extractFaqEntries, faqPageJsonLd, htmlToPlainText, injectStableIdsTree, isAllowedEmbedSrc, isAllowedMapEmbedSrc, isInCollectionMode, isValidBlock, issuePreviewToken, normalizeEmbed, normalizeImageAlt, parseBlock, postsForCollection, postsInAnyCollection, postsNotInAnyCollection, resolveCategoryPath, resolveCategoryTreeChain, resolveCategoryTreeEntryPath, resolveCategoryTreeHubPaths, resolvePostCategorySlug, resolvePostCollection, resolvePostPath, resolvePostUrl, sanitizeHtml, sanitizeImportedCss, sanitizeImportedHtml, scopeImportedCss, serializeBlock, validateCollections, verifyPreviewToken };
|
package/dist/index.js
CHANGED
|
@@ -127,18 +127,38 @@ function resolvePostCollection(post, collections) {
|
|
|
127
127
|
return collections.find((c) => c.key === post.collectionKey) ?? null;
|
|
128
128
|
}
|
|
129
129
|
function resolvePostUrl(siteUrl, post, collections) {
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
130
|
+
const path = resolvePostPath(post, collections);
|
|
131
|
+
return path ? `${trimTrailingSlash(siteUrl)}${path}` : null;
|
|
132
|
+
}
|
|
133
|
+
function resolvePostCategorySlug(post, collection) {
|
|
134
|
+
const allowed = new Set(collection.categories);
|
|
135
|
+
const slugs = [
|
|
136
|
+
...new Set(
|
|
137
|
+
post.terms.filter(
|
|
138
|
+
(term) => term.taxonomy === "category" && allowed.has(term.slug)
|
|
139
|
+
).map((term) => term.slug)
|
|
140
|
+
)
|
|
141
|
+
];
|
|
142
|
+
return slugs.length === 1 ? slugs[0] : null;
|
|
143
|
+
}
|
|
144
|
+
function resolveCategoryPath(collection, categorySlug) {
|
|
145
|
+
if (!collection.archives || !collection.basePath || !categorySlug) return null;
|
|
146
|
+
const basePath = trimTrailingSlash(collection.basePath);
|
|
147
|
+
const encodedSlug = encodeURIComponent(categorySlug);
|
|
148
|
+
return collection.categoryPath === "direct" ? `${basePath}/${encodedSlug}` : `${basePath}/categories/${encodedSlug}`;
|
|
135
149
|
}
|
|
136
150
|
function resolvePostPath(post, collections) {
|
|
137
151
|
const collection = resolvePostCollection(post, collections);
|
|
138
152
|
if (!collection) return null;
|
|
139
153
|
if (collection.detail === false) return null;
|
|
140
154
|
if (!collection.basePath) return null;
|
|
141
|
-
|
|
155
|
+
const basePath = trimTrailingSlash(collection.basePath);
|
|
156
|
+
const encodedPostSlug = encodeURIComponent(post.slug);
|
|
157
|
+
if (collection.detailPath !== "category") {
|
|
158
|
+
return `${basePath}/${encodedPostSlug}`;
|
|
159
|
+
}
|
|
160
|
+
const categorySlug = resolvePostCategorySlug(post, collection);
|
|
161
|
+
return categorySlug ? `${basePath}/${encodeURIComponent(categorySlug)}/${encodedPostSlug}` : null;
|
|
142
162
|
}
|
|
143
163
|
function postsForCollection(posts, collections, key) {
|
|
144
164
|
return posts.filter((p) => resolvePostCollection(p, collections)?.key === key);
|
|
@@ -178,10 +198,87 @@ function validateCollections(collections) {
|
|
|
178
198
|
}
|
|
179
199
|
categoryOwner.set(slug, c.key);
|
|
180
200
|
}
|
|
201
|
+
if (c.detailPath === "category") {
|
|
202
|
+
if (!c.basePath) {
|
|
203
|
+
problems.push(
|
|
204
|
+
`category \uC0C1\uC138 \uACBD\uB85C\uB294 basePath \uAC00 \uD544\uC694\uD568: "${c.key}"`
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
if (c.detail === false) {
|
|
208
|
+
problems.push(
|
|
209
|
+
`category \uC0C1\uC138 \uACBD\uB85C\uB294 \uAE00\uBCC4 \uC0C1\uC138 \uD398\uC774\uC9C0\uAC00 \uD544\uC694\uD568: "${c.key}"`
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
if (!c.archives) {
|
|
213
|
+
problems.push(
|
|
214
|
+
`category \uC0C1\uC138 \uACBD\uB85C\uB294 \uCE74\uD14C\uACE0\uB9AC \uC544\uCE74\uC774\uBE0C\uAC00 \uD544\uC694\uD568: "${c.key}"`
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
if (c.categoryCardinality !== "exactly-one") {
|
|
218
|
+
problems.push(
|
|
219
|
+
`category \uC0C1\uC138 \uACBD\uB85C\uB294 categoryCardinality "exactly-one" \uC774 \uD544\uC694\uD568: "${c.key}"`
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
181
223
|
}
|
|
182
224
|
return problems;
|
|
183
225
|
}
|
|
184
226
|
|
|
227
|
+
// src/category-tree.ts
|
|
228
|
+
function normalizeBasePath(basePath) {
|
|
229
|
+
return basePath.replace(/\/+$/, "");
|
|
230
|
+
}
|
|
231
|
+
function resolveCategoryTreeChain(presentation, leafId, terms) {
|
|
232
|
+
if (!Number.isInteger(presentation.categoryDepth) || presentation.categoryDepth < 1) {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
const termsById = new Map(terms.map((term) => [term.id, term]));
|
|
236
|
+
if (termsById.size !== terms.length) return null;
|
|
237
|
+
if (terms.some((term) => term.parentId === leafId)) return null;
|
|
238
|
+
const reversed = [];
|
|
239
|
+
const visited = /* @__PURE__ */ new Set();
|
|
240
|
+
let currentId = leafId;
|
|
241
|
+
while (currentId) {
|
|
242
|
+
if (visited.has(currentId)) return null;
|
|
243
|
+
visited.add(currentId);
|
|
244
|
+
const current = termsById.get(currentId);
|
|
245
|
+
if (!current || !current.slug) return null;
|
|
246
|
+
reversed.push(current);
|
|
247
|
+
currentId = current.parentId ?? null;
|
|
248
|
+
}
|
|
249
|
+
if (reversed.length !== presentation.categoryDepth) return null;
|
|
250
|
+
return reversed.reverse();
|
|
251
|
+
}
|
|
252
|
+
function resolveCategoryTreeHubPaths(presentation, termId, terms) {
|
|
253
|
+
const chain = resolveCategoryTreeChain(presentation, termId, terms);
|
|
254
|
+
const basePath = normalizeBasePath(presentation.basePath);
|
|
255
|
+
if (!chain || !basePath) return null;
|
|
256
|
+
const paths = [basePath];
|
|
257
|
+
const segments = [];
|
|
258
|
+
for (const term of chain) {
|
|
259
|
+
segments.push(encodeURIComponent(term.slug));
|
|
260
|
+
paths.push(`${basePath}/${segments.join("/")}`);
|
|
261
|
+
}
|
|
262
|
+
return paths;
|
|
263
|
+
}
|
|
264
|
+
function resolveCategoryTreeEntryPath(presentation, entry, terms) {
|
|
265
|
+
if (!entry.slug) return null;
|
|
266
|
+
const knownIds = new Set(terms.map((term) => term.id));
|
|
267
|
+
const categoryIds = [
|
|
268
|
+
...new Set(
|
|
269
|
+
entry.terms.filter((term) => term.taxonomy === "category" && knownIds.has(term.id)).map((term) => term.id)
|
|
270
|
+
)
|
|
271
|
+
];
|
|
272
|
+
if (categoryIds.length !== 1) return null;
|
|
273
|
+
const hubs = resolveCategoryTreeHubPaths(
|
|
274
|
+
presentation,
|
|
275
|
+
categoryIds[0],
|
|
276
|
+
terms
|
|
277
|
+
);
|
|
278
|
+
const leafPath = hubs?.at(-1);
|
|
279
|
+
return leafPath ? `${leafPath}/${encodeURIComponent(entry.slug)}` : null;
|
|
280
|
+
}
|
|
281
|
+
|
|
185
282
|
// src/delimiter.ts
|
|
186
283
|
function serializeBlock(block) {
|
|
187
284
|
const exportable = sanitizeAttributesForExport(block);
|
|
@@ -1179,6 +1276,11 @@ export {
|
|
|
1179
1276
|
postsForCollection,
|
|
1180
1277
|
postsInAnyCollection,
|
|
1181
1278
|
postsNotInAnyCollection,
|
|
1279
|
+
resolveCategoryPath,
|
|
1280
|
+
resolveCategoryTreeChain,
|
|
1281
|
+
resolveCategoryTreeEntryPath,
|
|
1282
|
+
resolveCategoryTreeHubPaths,
|
|
1283
|
+
resolvePostCategorySlug,
|
|
1182
1284
|
resolvePostCollection,
|
|
1183
1285
|
resolvePostPath,
|
|
1184
1286
|
resolvePostUrl,
|