@mintlify/common 1.0.1328 → 1.0.1330
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/dist/databases/formula/lower.js +1 -0
- package/dist/databases/formula/schema.js +1 -0
- package/dist/databases/formula/values.js +3 -1
- package/dist/databases/query/evaluate.js +5 -2
- package/dist/databases/query/index.d.ts +1 -1
- package/dist/databases/query/index.js +1 -1
- package/dist/databases/query/values.d.ts +1 -0
- package/dist/databases/query/values.js +4 -0
- package/dist/databases/view.d.ts +13 -4
- package/dist/databases/view.js +26 -12
- package/dist/mdx/plugins/remark/firstPartyMarkdownComponents.d.ts +6 -1
- package/dist/mdx/plugins/remark/firstPartyMarkdownComponents.js +9 -2
- package/dist/mdx/plugins/remark/remarkVisibilityForMarkdown.js +16 -1
- package/dist/navigation/index.d.ts +1 -0
- package/dist/navigation/index.js +1 -0
- package/dist/navigation/trimScopedNavPages.d.ts +1 -0
- package/dist/navigation/trimScopedNavPages.js +9 -2
- package/dist/navigation/trimScopedNavPages.test.js +26 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeDate } from '../query/values.js';
|
|
1
|
+
import { normalizeDate, pageTitle } from '../query/values.js';
|
|
2
2
|
import { isFormulaError } from './errors.js';
|
|
3
3
|
const isValidDate = (value) => value instanceof Date && !Number.isNaN(value.getTime());
|
|
4
4
|
const formatNumber = (value) => {
|
|
@@ -85,6 +85,8 @@ export const cellReader = (column, options) => {
|
|
|
85
85
|
case 'email':
|
|
86
86
|
case 'person':
|
|
87
87
|
return toText;
|
|
88
|
+
case 'page':
|
|
89
|
+
return pageTitle;
|
|
88
90
|
default:
|
|
89
91
|
return (raw) => raw instanceof Date
|
|
90
92
|
? isValidDate(raw)
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { CLIENT_ONLY, QUERY_LIMITS, } from './types.js';
|
|
2
2
|
import { validateQueryExpr, validateQueryRequest } from './validate.js';
|
|
3
|
-
import { asciiLower, compareCodePoints, normalizeDate } from './values.js';
|
|
3
|
+
import { asciiLower, compareCodePoints, normalizeDate, pageTitle } from './values.js';
|
|
4
4
|
const KINDS = {
|
|
5
5
|
text: 'text',
|
|
6
6
|
url: 'text',
|
|
7
7
|
email: 'text',
|
|
8
8
|
person: 'text',
|
|
9
|
+
page: 'text',
|
|
9
10
|
number: 'number',
|
|
10
11
|
boolean: 'boolean',
|
|
11
12
|
date: 'date',
|
|
@@ -253,7 +254,9 @@ class Compiler {
|
|
|
253
254
|
id: column.id,
|
|
254
255
|
type: column.type,
|
|
255
256
|
kind,
|
|
256
|
-
read:
|
|
257
|
+
read: column.type === 'page'
|
|
258
|
+
? (row) => readScalar(kind, pageTitle(row.columns[column.id]))
|
|
259
|
+
: (row) => readScalar(kind, row.columns[column.id]),
|
|
257
260
|
};
|
|
258
261
|
}
|
|
259
262
|
operand(expr, path) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { compensatedSum, compileQueryFilter, evaluateQuery, type EvaluateQueryOptions, measureQuery, type QueryError, type QueryResult, type RowPredicate, } from './evaluate.js';
|
|
2
2
|
export * from './types.js';
|
|
3
3
|
export { isValidQueryRequest, validateQueryExpr, validateQueryRequest } from './validate.js';
|
|
4
|
-
export { asciiLower, compareCodePoints, isEmptyValue, normalizeDate } from './values.js';
|
|
4
|
+
export { asciiLower, compareCodePoints, isEmptyValue, normalizeDate, pageTitle } from './values.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { compensatedSum, compileQueryFilter, evaluateQuery, measureQuery, } from './evaluate.js';
|
|
2
2
|
export * from './types.js';
|
|
3
3
|
export { isValidQueryRequest, validateQueryExpr, validateQueryRequest } from './validate.js';
|
|
4
|
-
export { asciiLower, compareCodePoints, isEmptyValue, normalizeDate } from './values.js';
|
|
4
|
+
export { asciiLower, compareCodePoints, isEmptyValue, normalizeDate, pageTitle } from './values.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const normalizeDate: (value: unknown) => string | null;
|
|
2
|
+
export declare const pageTitle: (value: unknown) => string | null;
|
|
2
3
|
export declare const isEmptyValue: (value: unknown) => boolean;
|
|
3
4
|
export declare const asciiLower: (value: string) => string;
|
|
4
5
|
export declare const compareCodePoints: (a: string, b: string) => -1 | 0 | 1;
|
|
@@ -13,6 +13,10 @@ export const normalizeDate = (value) => {
|
|
|
13
13
|
const time = Date.parse(value);
|
|
14
14
|
return valid && !Number.isNaN(time) ? new Date(time).toISOString() : null;
|
|
15
15
|
};
|
|
16
|
+
// A page cell is stored as { pageId, title, href }; filters, sorts and formulas read its title.
|
|
17
|
+
export const pageTitle = (value) => typeof value === 'object' && value !== null && 'title' in value && typeof value.title === 'string'
|
|
18
|
+
? value.title
|
|
19
|
+
: null;
|
|
16
20
|
export const isEmptyValue = (value) => value === null ||
|
|
17
21
|
value === undefined ||
|
|
18
22
|
value === '' ||
|
package/dist/databases/view.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { type QuerySort } from './query/types.js';
|
|
2
2
|
export { columnReference } from './formula/format.js';
|
|
3
|
-
export declare const DATABASE_VIEWS: readonly ['table', 'board'];
|
|
3
|
+
export declare const DATABASE_VIEWS: readonly ['table', 'board', 'calendar'];
|
|
4
4
|
export type DatabaseView = (typeof DATABASE_VIEWS)[number];
|
|
5
5
|
export type DatabaseViewProps = {
|
|
6
6
|
view?: string | null;
|
|
7
7
|
sort?: string | null;
|
|
8
8
|
filter?: string | null;
|
|
9
9
|
groupBy?: string | null;
|
|
10
|
+
calendarBy?: string | null;
|
|
10
11
|
};
|
|
11
|
-
export type DatabaseViewPropChanges = Pick<DatabaseViewProps, 'view' | 'sort' | 'filter' | 'groupBy'>;
|
|
12
|
+
export type DatabaseViewPropChanges = Pick<DatabaseViewProps, 'view' | 'sort' | 'filter' | 'groupBy' | 'calendarBy'>;
|
|
12
13
|
export type DatabaseViewColumn = {
|
|
13
14
|
id: string;
|
|
14
15
|
name: string;
|
|
@@ -79,13 +80,18 @@ export type DatabaseViewWarning = {
|
|
|
79
80
|
kind: 'group_by_unsupported';
|
|
80
81
|
column: string;
|
|
81
82
|
type: string;
|
|
83
|
+
} | {
|
|
84
|
+
kind: 'calendar_by_unsupported';
|
|
85
|
+
column: string;
|
|
86
|
+
type: string;
|
|
82
87
|
};
|
|
83
|
-
export type DatabaseViewPropName = 'sort' | 'filter' | 'groupBy';
|
|
88
|
+
export type DatabaseViewPropName = 'sort' | 'filter' | 'groupBy' | 'calendarBy';
|
|
84
89
|
export type DatabaseFilterKind = 'text' | 'number' | 'select' | 'multi' | 'checkbox' | 'date';
|
|
85
90
|
export declare const filterKindOf: (type: string) => DatabaseFilterKind | null;
|
|
86
91
|
export declare const isViewableColumn: (column: Pick<DatabaseViewColumn, 'type'>) => boolean;
|
|
87
92
|
export declare const isSortableColumn: (column: Pick<DatabaseViewColumn, 'type'>) => boolean;
|
|
88
93
|
export declare const isGroupableColumn: (column: Pick<DatabaseViewColumn, 'type'>) => boolean;
|
|
94
|
+
export declare const isCalendarColumn: (column: Pick<DatabaseViewColumn, 'type'>) => boolean;
|
|
89
95
|
export declare const filterOpsFor: (type: string) => readonly DatabaseFilterOp[];
|
|
90
96
|
export declare const isKnownView: (value: unknown) => value is DatabaseView;
|
|
91
97
|
export declare const resolveView: (value: unknown) => DatabaseView;
|
|
@@ -119,11 +125,13 @@ export declare const renameColumnsInViewProps: (props: DatabaseViewProps, rename
|
|
|
119
125
|
export declare const renameColumnInViewProps: (props: DatabaseViewProps, from: string, to: string) => DatabaseViewPropChanges;
|
|
120
126
|
export declare const aliasRenames: (columns: readonly DatabaseViewColumn[]) => DatabaseColumnRenames;
|
|
121
127
|
export declare const ambiguousAliases: (columns: readonly DatabaseViewColumn[]) => ReadonlySet<string>;
|
|
122
|
-
export type
|
|
128
|
+
export type ResolvedColumnProp = {
|
|
123
129
|
column: DatabaseViewColumn | null;
|
|
124
130
|
warnings: DatabaseViewWarning[];
|
|
125
131
|
};
|
|
132
|
+
export type ResolvedGroupBy = ResolvedColumnProp;
|
|
126
133
|
export declare const resolveGroupBy: (written: string | null | undefined, columns: readonly DatabaseViewColumn[]) => ResolvedGroupBy;
|
|
134
|
+
export declare const resolveCalendarBy: (written: string | null | undefined, columns: readonly DatabaseViewColumn[]) => ResolvedColumnProp;
|
|
127
135
|
export type DatabaseInvalidFilter = 'show-all' | 'hide-all';
|
|
128
136
|
export type ResolveViewOptions = {
|
|
129
137
|
onInvalidFilter?: DatabaseInvalidFilter;
|
|
@@ -133,6 +141,7 @@ export type ResolvedDatabaseView = {
|
|
|
133
141
|
sort: DatabaseSortRule[];
|
|
134
142
|
filter: DatabaseFilter;
|
|
135
143
|
groupBy: string | null;
|
|
144
|
+
calendarBy: string | null;
|
|
136
145
|
warnings: DatabaseViewWarning[];
|
|
137
146
|
healed: DatabaseViewPropChanges;
|
|
138
147
|
filterSource: string | null;
|
package/dist/databases/view.js
CHANGED
|
@@ -9,7 +9,7 @@ import { evaluateQuery } from './query/evaluate.js';
|
|
|
9
9
|
import { QUERY_LIMITS } from './query/types.js';
|
|
10
10
|
import { normalizeDate } from './query/values.js';
|
|
11
11
|
export { columnReference } from './formula/format.js';
|
|
12
|
-
export const DATABASE_VIEWS = ['table', 'board'];
|
|
12
|
+
export const DATABASE_VIEWS = ['table', 'board', 'calendar'];
|
|
13
13
|
export const DATABASE_FILTER_OPS = [
|
|
14
14
|
'eq',
|
|
15
15
|
'neq',
|
|
@@ -29,6 +29,7 @@ const FILTER_KINDS = {
|
|
|
29
29
|
url: 'text',
|
|
30
30
|
email: 'text',
|
|
31
31
|
person: 'text',
|
|
32
|
+
page: 'text',
|
|
32
33
|
number: 'number',
|
|
33
34
|
select: 'select',
|
|
34
35
|
multi_select: 'multi',
|
|
@@ -39,6 +40,7 @@ export const filterKindOf = (type) => { var _a; return (_a = FILTER_KINDS[type])
|
|
|
39
40
|
export const isViewableColumn = (column) => filterKindOf(column.type) !== null;
|
|
40
41
|
export const isSortableColumn = (column) => isViewableColumn(column) && column.type !== 'multi_select';
|
|
41
42
|
export const isGroupableColumn = (column) => column.type === 'select';
|
|
43
|
+
export const isCalendarColumn = (column) => column.type === 'date';
|
|
42
44
|
const OPS_BY_KIND = {
|
|
43
45
|
text: ['contains', 'not_contains', 'eq', 'neq', 'empty', 'not_empty'],
|
|
44
46
|
number: ['eq', 'neq', 'lt', 'lte', 'gt', 'gte', 'empty', 'not_empty'],
|
|
@@ -362,7 +364,7 @@ export const resolveColumnName = (written, candidates) => {
|
|
|
362
364
|
return { column: null, reason: loose.length > 1 ? 'ambiguous' : 'unknown' };
|
|
363
365
|
};
|
|
364
366
|
export const matchColumnName = (written, candidates) => { var _a; return (_a = resolveColumnName(written, candidates).column) !== null && _a !== void 0 ? _a : undefined; };
|
|
365
|
-
const
|
|
367
|
+
const renamedColumnProp = (written, renames) => { var _a; return (_a = matchColumnName(written, [...renames].map(([name, to]) => ({ name, to })))) === null || _a === void 0 ? void 0 : _a.to; };
|
|
366
368
|
export const renameColumnsInViewProps = (props, renames) => {
|
|
367
369
|
const changes = {};
|
|
368
370
|
if (renames.size === 0)
|
|
@@ -374,7 +376,10 @@ export const renameColumnsInViewProps = (props, renames) => {
|
|
|
374
376
|
};
|
|
375
377
|
const filter = props.filter ? renameFormula(props.filter, renames) : props.filter;
|
|
376
378
|
const groupBy = props.groupBy
|
|
377
|
-
?
|
|
379
|
+
? renamedColumnProp(normalizeColumnName(props.groupBy), renames)
|
|
380
|
+
: undefined;
|
|
381
|
+
const calendarBy = props.calendarBy
|
|
382
|
+
? renamedColumnProp(normalizeColumnName(props.calendarBy), renames)
|
|
378
383
|
: undefined;
|
|
379
384
|
if (keys.some(({ rule }) => rule && renames.has(rule.column))) {
|
|
380
385
|
changes.sort = keys.map(renamedKey).join(', ');
|
|
@@ -383,6 +388,8 @@ export const renameColumnsInViewProps = (props, renames) => {
|
|
|
383
388
|
changes.filter = filter;
|
|
384
389
|
if (groupBy !== undefined)
|
|
385
390
|
changes.groupBy = groupBy;
|
|
391
|
+
if (calendarBy !== undefined)
|
|
392
|
+
changes.calendarBy = calendarBy;
|
|
386
393
|
return changes;
|
|
387
394
|
};
|
|
388
395
|
export const renameColumnInViewProps = (props, from, to) => renameColumnsInViewProps(props, new Map([[from, to]]));
|
|
@@ -413,24 +420,26 @@ export const ambiguousAliases = (columns) => new Set([...aliasTargets(columns)].
|
|
|
413
420
|
const nameWarning = (prop, column, reason, columns) => reason === 'ambiguous' || ambiguousAliases(columns).has(column)
|
|
414
421
|
? { kind: 'ambiguous_column', prop, column }
|
|
415
422
|
: { kind: 'unknown_column', prop, column };
|
|
416
|
-
|
|
423
|
+
const resolveColumnProp = (prop, written, columns, accepts, unsupported) => {
|
|
417
424
|
var _a;
|
|
418
425
|
const name = written ? normalizeColumnName(written) : '';
|
|
419
426
|
if (!name)
|
|
420
|
-
return { column: (_a = columns.find(
|
|
427
|
+
return { column: (_a = columns.find(accepts)) !== null && _a !== void 0 ? _a : null, warnings: [] };
|
|
421
428
|
const match = resolveColumnName(name, columns);
|
|
422
429
|
if (!match.column) {
|
|
423
|
-
return { column: null, warnings: [nameWarning(
|
|
430
|
+
return { column: null, warnings: [nameWarning(prop, name, match.reason, columns)] };
|
|
424
431
|
}
|
|
425
432
|
const { column } = match;
|
|
426
|
-
if (!
|
|
433
|
+
if (!accepts(column)) {
|
|
427
434
|
return {
|
|
428
435
|
column: null,
|
|
429
|
-
warnings: [{ kind:
|
|
436
|
+
warnings: [{ kind: unsupported, column: column.name, type: column.type }],
|
|
430
437
|
};
|
|
431
438
|
}
|
|
432
439
|
return { column, warnings: [] };
|
|
433
440
|
};
|
|
441
|
+
export const resolveGroupBy = (written, columns) => resolveColumnProp('groupBy', written, columns, isGroupableColumn, 'group_by_unsupported');
|
|
442
|
+
export const resolveCalendarBy = (written, columns) => resolveColumnProp('calendarBy', written, columns, isCalendarColumn, 'calendar_by_unsupported');
|
|
434
443
|
const ALL_ROWS = () => true;
|
|
435
444
|
const NO_ROWS = () => false;
|
|
436
445
|
const canonicalNames = (source, columns, warn) => {
|
|
@@ -451,11 +460,13 @@ const canonicalNames = (source, columns, warn) => {
|
|
|
451
460
|
return canonical;
|
|
452
461
|
};
|
|
453
462
|
export const resolveViewProps = (written, columns, { onInvalidFilter = 'show-all' } = {}) => {
|
|
454
|
-
var _a, _b;
|
|
455
|
-
var
|
|
463
|
+
var _a, _b, _c;
|
|
464
|
+
var _d, _e, _f;
|
|
456
465
|
const healed = renameColumnsInViewProps(written, aliasRenames(columns));
|
|
457
466
|
if (written.groupBy && matchColumnName(written.groupBy, columns))
|
|
458
467
|
delete healed.groupBy;
|
|
468
|
+
if (written.calendarBy && matchColumnName(written.calendarBy, columns))
|
|
469
|
+
delete healed.calendarBy;
|
|
459
470
|
const props = Object.assign(Object.assign({}, written), healed);
|
|
460
471
|
const warnings = [];
|
|
461
472
|
let filterInvalid = false;
|
|
@@ -479,7 +490,7 @@ export const resolveViewProps = (written, columns, { onInvalidFilter = 'show-all
|
|
|
479
490
|
continue;
|
|
480
491
|
}
|
|
481
492
|
const column = known('sort', key.rule.column);
|
|
482
|
-
const rule = { column: (
|
|
493
|
+
const rule = { column: (_d = column === null || column === void 0 ? void 0 : column.name) !== null && _d !== void 0 ? _d : key.rule.column, direction: key.rule.direction };
|
|
483
494
|
sort.push(rule);
|
|
484
495
|
if (!column)
|
|
485
496
|
continue;
|
|
@@ -542,11 +553,14 @@ export const resolveViewProps = (written, columns, { onInvalidFilter = 'show-all
|
|
|
542
553
|
const stored = filterSource ? toStoredFormula(filterSource, columns) : null;
|
|
543
554
|
const group = resolveGroupBy(props.groupBy, columns);
|
|
544
555
|
warnings.push(...group.warnings);
|
|
556
|
+
const calendar = resolveCalendarBy(props.calendarBy, columns);
|
|
557
|
+
warnings.push(...calendar.warnings);
|
|
545
558
|
return {
|
|
546
559
|
view: resolveView(rawView),
|
|
547
560
|
sort,
|
|
548
561
|
filter,
|
|
549
|
-
groupBy: (
|
|
562
|
+
groupBy: (_e = (_b = group.column) === null || _b === void 0 ? void 0 : _b.name) !== null && _e !== void 0 ? _e : null,
|
|
563
|
+
calendarBy: (_f = (_c = calendar.column) === null || _c === void 0 ? void 0 : _c.name) !== null && _f !== void 0 ? _f : null,
|
|
550
564
|
warnings,
|
|
551
565
|
healed,
|
|
552
566
|
filterSource: matches === ALL_ROWS || matches === NO_ROWS ? null : filterSource,
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
/** Label for a link that follows block content when nothing names its target. */
|
|
2
2
|
export declare const BLOCK_LINK_LABEL = "Open";
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const BLOCK_MARKERS: {
|
|
4
|
+
readonly Tab: '[tab]';
|
|
5
|
+
readonly Card: '[card]';
|
|
6
|
+
readonly Accordion: '[accordion]';
|
|
7
|
+
};
|
|
8
|
+
export declare const FIRST_PARTY_MARKDOWN_COMPONENT_SOURCE: string;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/** Label for a link that follows block content when nothing names its target. */
|
|
2
2
|
export const BLOCK_LINK_LABEL = 'Open';
|
|
3
|
+
export const BLOCK_MARKERS = {
|
|
4
|
+
Tab: '[tab]',
|
|
5
|
+
Card: '[card]',
|
|
6
|
+
Accordion: '[accordion]',
|
|
7
|
+
};
|
|
3
8
|
export const FIRST_PARTY_MARKDOWN_COMPONENT_SOURCE = `
|
|
4
9
|
export const Note = ({ children }) => <blockquote>{"[!NOTE]\\n\\n"}{children}</blockquote>;
|
|
5
10
|
|
|
@@ -13,14 +18,16 @@ export const Warning = ({ children }) => <blockquote>{"[!WARNING]\\n\\n"}{childr
|
|
|
13
18
|
|
|
14
19
|
export const Danger = ({ children }) => <blockquote>{"[!CAUTION]\\n\\n"}{children}</blockquote>;
|
|
15
20
|
|
|
16
|
-
export const Card = ({ title = "", href = "", description = "", children }) => title === "" ? <
|
|
21
|
+
export const Card = ({ title = "", href = "", description = "", children }) => <blockquote>{"${BLOCK_MARKERS.Card}"}{title === "" ? "" : <>{" "}<a href={href}>{title}</a></>}{"\\n\\n"}{(children ?? "") === "" ? description : children}{title !== "" || href === "" ? "" : <>{"\\n\\n"}<a href={href}>${BLOCK_LINK_LABEL}</a></>}</blockquote>;
|
|
17
22
|
|
|
18
|
-
export const Accordion = ({ title = "", description = "", children }) => <blockquote>{title === "" ? "" :
|
|
23
|
+
export const Accordion = ({ title = "", description = "", children }) => <blockquote>{"${BLOCK_MARKERS.Accordion}"}{title === "" ? "" : " " + title}{"\\n\\n"}{description === "" ? "" : <>{description}{"\\n\\n"}</>}{children}</blockquote>;
|
|
19
24
|
|
|
20
25
|
export const ParamField = ({ path = "", body = "", query = "", header = "", type = "", required = false, deprecated = false, default: defaultValue = "", children }) => (path || body || query || header) === "" ? <>{children}</> : <>{"**" + (path || body || query || header) + "**"}{type === "" ? "" : " \\\`" + type + "\\\`"}{required ? " *required*" : ""}{deprecated ? " *deprecated*" : ""}{defaultValue === "" ? "" : " (default: " + defaultValue + ")"}{"\\n\\n"}{children}</>;
|
|
21
26
|
|
|
22
27
|
export const ResponseField = ({ name = "", type = "", required = false, deprecated = false, default: defaultValue = "", children }) => name === "" ? <>{children}</> : <>{"**" + name + "**"}{type === "" ? "" : " \\\`" + type + "\\\`"}{required ? " *required*" : ""}{deprecated ? " *deprecated*" : ""}{defaultValue === "" ? "" : " (default: " + defaultValue + ")"}{"\\n\\n"}{children}</>;
|
|
23
28
|
|
|
29
|
+
export const Tab = ({ title = "", children }) => <blockquote>{"${BLOCK_MARKERS.Tab}"}{title === "" ? "" : " " + title}{"\\n\\n"}{children}</blockquote>;
|
|
30
|
+
|
|
24
31
|
export const Steps = ({ children }) => <>{children}</>;
|
|
25
32
|
|
|
26
33
|
export const Step = ({ title = "", stepNumber = 1, titleSize = "p", children }) => <>{"\\n\\n"}{titleSize === "h2" ? "## " : titleSize === "h3" ? "### " : titleSize === "h4" ? "#### " : "**"}{title === "" ? "Step " + stepNumber : stepNumber + ". " + title}{titleSize === "h2" || titleSize === "h3" || titleSize === "h4" ? "" : "**"}{"\\n\\n"}{children}{"\\n\\n"}</>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getAST, stringifyTree } from '../../remark-core.js';
|
|
2
|
-
import { BLOCK_LINK_LABEL } from './firstPartyMarkdownComponents.js';
|
|
2
|
+
import { BLOCK_LINK_LABEL, BLOCK_MARKERS } from './firstPartyMarkdownComponents.js';
|
|
3
3
|
import { evaluateStatic } from './staticEvaluator.js';
|
|
4
4
|
import { chargeUnfoldBudget, chargeUnfoldCall, collectMarkdownComponentContext, collectUsageProps, containsJsx, createUnfoldBudget, definitionGatesContent, DROP_ELEMENTS, FORM_CONTROL_ELEMENTS, dropPairedDarkOnly, escapeInterpolatedText, HEADING_ELEMENTS, isPresentationalAttribute, UNWRAP_BLOCK_ELEMENTS, UNWRAP_INLINE_ELEMENTS, escapeLinkLabel, extractProgramExpression, FAILED_SPREAD, markdownLinkDestination, MAX_UNFOLD_DEPTH, GFM_ALERT_PATTERN, HEADLINE_ATTRIBUTES, KEEP_TAG_COMPONENTS, materializeComponent, serializeExpressionJsx, } from './unfoldComponentsForMarkdown.js';
|
|
5
5
|
import { toVisibilityGroups, toVisibilityGroupsRule, } from './visibility-auth-rule.js';
|
|
@@ -859,6 +859,14 @@ function replaceChildren(children, next) {
|
|
|
859
859
|
children.length = 0;
|
|
860
860
|
children.push(...next);
|
|
861
861
|
}
|
|
862
|
+
function findBlockMarker(value) {
|
|
863
|
+
return Object.values(BLOCK_MARKERS).find((marker) => {
|
|
864
|
+
if (!value.startsWith(marker))
|
|
865
|
+
return false;
|
|
866
|
+
const next = value.charAt(marker.length);
|
|
867
|
+
return next === '' || next === ' ' || next === '\n';
|
|
868
|
+
});
|
|
869
|
+
}
|
|
862
870
|
function normalizeGfmAlerts(nodes) {
|
|
863
871
|
for (const node of nodes) {
|
|
864
872
|
if (node.type === 'blockquote') {
|
|
@@ -879,6 +887,13 @@ function normalizeGfmAlerts(nodes) {
|
|
|
879
887
|
}
|
|
880
888
|
node.children.unshift({ type: 'html', value: match[0] });
|
|
881
889
|
}
|
|
890
|
+
else {
|
|
891
|
+
const marker = findBlockMarker(firstChild.value);
|
|
892
|
+
if (marker !== undefined) {
|
|
893
|
+
const remainder = firstChild.value.slice(marker.length);
|
|
894
|
+
first.children.splice(0, 1, { type: 'html', value: marker }, ...(remainder === '' ? [] : [Object.assign(Object.assign({}, firstChild), { value: remainder })]));
|
|
895
|
+
}
|
|
896
|
+
}
|
|
882
897
|
}
|
|
883
898
|
}
|
|
884
899
|
}
|
|
@@ -12,6 +12,7 @@ export * from './groupAccess.js';
|
|
|
12
12
|
export * from './filterDivisions.js';
|
|
13
13
|
export * from './updateFirstHrefInDivision.js';
|
|
14
14
|
export * from './scopeNavToPath.js';
|
|
15
|
+
export { trimNavPagesToClientFields } from './trimScopedNavPages.js';
|
|
15
16
|
export * from './getVersionOrLanguageFromPath.js';
|
|
16
17
|
export * from './isCommonPage.js';
|
|
17
18
|
export * from './getFirstPageFromNavConfig.js';
|
package/dist/navigation/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export * from './groupAccess.js';
|
|
|
12
12
|
export * from './filterDivisions.js';
|
|
13
13
|
export * from './updateFirstHrefInDivision.js';
|
|
14
14
|
export * from './scopeNavToPath.js';
|
|
15
|
+
export { trimNavPagesToClientFields } from './trimScopedNavPages.js';
|
|
15
16
|
export * from './getVersionOrLanguageFromPath.js';
|
|
16
17
|
export * from './isCommonPage.js';
|
|
17
18
|
export * from './getFirstPageFromNavConfig.js';
|
|
@@ -95,7 +95,7 @@ function trimNode(node, keepDescription) {
|
|
|
95
95
|
if (!isNavNode(node))
|
|
96
96
|
return node;
|
|
97
97
|
if (isPageNode(node))
|
|
98
|
-
return trimPage(node, keepDescription
|
|
98
|
+
return trimPage(node, keepDescription(node));
|
|
99
99
|
const trimmed = {};
|
|
100
100
|
for (const [key, value] of Object.entries(node)) {
|
|
101
101
|
trimmed[key] = key === 'global' ? value : trimNode(value, keepDescription);
|
|
@@ -107,6 +107,13 @@ export function trimScopedNavPages(nav, currentPath) {
|
|
|
107
107
|
const target = normalizeComparablePath(replaceSlashIndex(currentPath));
|
|
108
108
|
addPaginationNeighbors(nav, target, keepDescription);
|
|
109
109
|
addDirectoryChildren(nav, target, keepDescription);
|
|
110
|
-
const trimmed = trimNode(nav, keepDescription);
|
|
110
|
+
const trimmed = trimNode(nav, (page) => keepDescription.has(page));
|
|
111
|
+
return isNavNode(trimmed) ? trimmed : nav;
|
|
112
|
+
}
|
|
113
|
+
// static export renders one layout nav into every page, so it can't know which
|
|
114
|
+
// pages need descriptions; keep them all and drop everything else the client
|
|
115
|
+
// doesn't read (keywords, custom frontmatter)
|
|
116
|
+
export function trimNavPagesToClientFields(nav) {
|
|
117
|
+
const trimmed = trimNode(nav, () => true);
|
|
111
118
|
return isNavNode(trimmed) ? trimmed : nav;
|
|
112
119
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { trimScopedNavPages } from './trimScopedNavPages.js';
|
|
1
|
+
import { trimNavPagesToClientFields, trimScopedNavPages } from './trimScopedNavPages.js';
|
|
2
2
|
const page = (slug, extra = {}) => (Object.assign({ title: slug, href: `/${slug}`, description: `${slug} description` }, extra));
|
|
3
3
|
function descriptions(nav) {
|
|
4
4
|
const out = {};
|
|
@@ -192,3 +192,28 @@ describe('trimScopedNavPages', () => {
|
|
|
192
192
|
expect(nav).toEqual(before);
|
|
193
193
|
});
|
|
194
194
|
});
|
|
195
|
+
describe('trimNavPagesToClientFields', () => {
|
|
196
|
+
it('keeps client fields and every description', () => {
|
|
197
|
+
const nav = {
|
|
198
|
+
groups: [
|
|
199
|
+
{
|
|
200
|
+
group: 'G',
|
|
201
|
+
root: page('g', { keywords: ['k'] }),
|
|
202
|
+
pages: [page('a', { icon: 'book', customFrontmatter: 'x' }), page('b', { tag: 'New' })],
|
|
203
|
+
},
|
|
204
|
+
],
|
|
205
|
+
};
|
|
206
|
+
expect(trimNavPagesToClientFields(nav)).toEqual({
|
|
207
|
+
groups: [
|
|
208
|
+
{
|
|
209
|
+
group: 'G',
|
|
210
|
+
root: { title: 'g', href: '/g', description: 'g description' },
|
|
211
|
+
pages: [
|
|
212
|
+
{ title: 'a', href: '/a', description: 'a description', icon: 'book' },
|
|
213
|
+
{ title: 'b', href: '/b', description: 'b description', tag: 'New' },
|
|
214
|
+
],
|
|
215
|
+
},
|
|
216
|
+
],
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
});
|