@takeshape/ssg 11.144.1 → 11.154.1
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 +5 -5
- package/dist/compress-html.d.ts +0 -3
- package/dist/compress-html.js +0 -20
- package/dist/config.d.ts +0 -76
- package/dist/config.js +0 -106
- package/dist/errors/formatting.d.ts +0 -4
- package/dist/errors/formatting.js +0 -8
- package/dist/errors/graphql-error.d.ts +0 -6
- package/dist/errors/graphql-error.js +0 -22
- package/dist/errors/index.d.ts +0 -5
- package/dist/errors/index.js +0 -5
- package/dist/errors/pagination-error.d.ts +0 -3
- package/dist/errors/pagination-error.js +0 -6
- package/dist/errors/template-render-error.d.ts +0 -4
- package/dist/errors/template-render-error.js +0 -11
- package/dist/files.d.ts +0 -3
- package/dist/files.js +0 -11
- package/dist/filters/array-filters.d.ts +0 -2
- package/dist/filters/array-filters.js +0 -2
- package/dist/filters/code-filter.d.ts +0 -1
- package/dist/filters/code-filter.js +0 -13
- package/dist/filters/create-asset-filter.d.ts +0 -1
- package/dist/filters/create-asset-filter.js +0 -5
- package/dist/filters/create-date-filter.d.ts +0 -2
- package/dist/filters/create-date-filter.js +0 -12
- package/dist/filters/create-image-filter.d.ts +0 -2
- package/dist/filters/create-image-filter.js +0 -7
- package/dist/filters/create-number-filter.d.ts +0 -3
- package/dist/filters/create-number-filter.js +0 -120
- package/dist/filters/create-route-filter.d.ts +0 -3
- package/dist/filters/create-route-filter.js +0 -24
- package/dist/filters/markdown-filter.d.ts +0 -1
- package/dist/filters/markdown-filter.js +0 -6
- package/dist/filters/pluralize-filter.d.ts +0 -1
- package/dist/filters/pluralize-filter.js +0 -4
- package/dist/generate/context.d.ts +0 -8
- package/dist/generate/context.js +0 -49
- package/dist/generate/generate.d.ts +0 -21
- package/dist/generate/generate.js +0 -300
- package/dist/generate/index.d.ts +0 -1
- package/dist/generate/index.js +0 -1
- package/dist/generate/streams.d.ts +0 -7
- package/dist/generate/streams.js +0 -88
- package/dist/generate/types.d.ts +0 -54
- package/dist/generate/types.js +0 -1
- package/dist/graphql/analyze.d.ts +0 -28
- package/dist/graphql/analyze.js +0 -87
- package/dist/graphql/ast.d.ts +0 -19
- package/dist/graphql/ast.js +0 -122
- package/dist/graphql/client-schema.d.ts +0 -3
- package/dist/graphql/client-schema.js +0 -8
- package/dist/graphql/index.d.ts +0 -6
- package/dist/graphql/index.js +0 -6
- package/dist/graphql/migrate.d.ts +0 -19
- package/dist/graphql/migrate.js +0 -111
- package/dist/graphql/pagination.d.ts +0 -36
- package/dist/graphql/pagination.js +0 -268
- package/dist/graphql/query.d.ts +0 -20
- package/dist/graphql/query.js +0 -141
- package/dist/graphql/schema-connector-factory.d.ts +0 -10
- package/dist/graphql/schema-connector-factory.js +0 -90
- package/dist/gzip.d.ts +0 -3
- package/dist/gzip.js +0 -14
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -6
- package/dist/nunjucks.d.ts +0 -7
- package/dist/nunjucks.js +0 -88
- package/dist/paths.d.ts +0 -2
- package/dist/paths.js +0 -10
- package/dist/resolve-context.d.ts +0 -34
- package/dist/resolve-context.js +0 -115
- package/dist/stats.d.ts +0 -4
- package/dist/stats.js +0 -39
- package/dist/types.d.ts +0 -53
- package/dist/types.js +0 -1
- package/dist/util.d.ts +0 -2
- package/dist/util.js +0 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/ssg",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.154.1",
|
|
4
4
|
"description": "Static Site Generator",
|
|
5
5
|
"homepage": "https://www.takeshape.io",
|
|
6
6
|
"repository": {
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"pluralize": "8.0.0",
|
|
43
43
|
"pumpify": "2.0.1",
|
|
44
44
|
"resolve": "1.22.8",
|
|
45
|
-
"@takeshape/
|
|
46
|
-
"@takeshape/
|
|
47
|
-
"@takeshape/
|
|
48
|
-
"@takeshape/util": "11.
|
|
45
|
+
"@takeshape/prism": "11.154.1",
|
|
46
|
+
"@takeshape/routing": "11.154.1",
|
|
47
|
+
"@takeshape/streams": "11.154.1",
|
|
48
|
+
"@takeshape/util": "11.154.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/bluebird": "3.5.33",
|
package/dist/compress-html.d.ts
DELETED
package/dist/compress-html.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import Minimize from 'minimize';
|
|
2
|
-
const defaultOptions = {
|
|
3
|
-
loose: true
|
|
4
|
-
};
|
|
5
|
-
export default function compressHtml(config) {
|
|
6
|
-
return (renderTemplate) => {
|
|
7
|
-
config.options = { ...defaultOptions, ...config.options };
|
|
8
|
-
const minimize = new Minimize(config.options);
|
|
9
|
-
return async (path, template, context) => {
|
|
10
|
-
const item = await renderTemplate(path, template, context);
|
|
11
|
-
if (item.path.endsWith('.html')) {
|
|
12
|
-
return {
|
|
13
|
-
path: item.path,
|
|
14
|
-
contents: minimize.parse(item.contents)
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
return item;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
}
|
package/dist/config.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { FormatLocaleDefinition } from 'd3-format';
|
|
2
|
-
import type { Data } from './types.ts';
|
|
3
|
-
export type GraphQLQueryConfig = {
|
|
4
|
-
query: string;
|
|
5
|
-
variables?: Record<string, any>;
|
|
6
|
-
};
|
|
7
|
-
export type ContextConfig = string | GraphQLQueryConfig | Data;
|
|
8
|
-
export type PaginateConfig = {
|
|
9
|
-
template?: string;
|
|
10
|
-
pageSize: number;
|
|
11
|
-
firstPage?: string;
|
|
12
|
-
path?: string;
|
|
13
|
-
data?: string | GraphQLQueryConfig;
|
|
14
|
-
itemName?: string;
|
|
15
|
-
property?: string;
|
|
16
|
-
};
|
|
17
|
-
export type RouteConfig = {
|
|
18
|
-
path: string;
|
|
19
|
-
template: string;
|
|
20
|
-
context?: ContextConfig;
|
|
21
|
-
paginate?: PaginateConfig;
|
|
22
|
-
};
|
|
23
|
-
export type ResolvedRouteConfig = {
|
|
24
|
-
context: Data;
|
|
25
|
-
} & Omit<RouteConfig, 'context'>;
|
|
26
|
-
export type DatesConfig = {
|
|
27
|
-
tz: string;
|
|
28
|
-
format: string;
|
|
29
|
-
locale?: string;
|
|
30
|
-
};
|
|
31
|
-
export type NumbersConfig = {
|
|
32
|
-
format?: string;
|
|
33
|
-
config?: Partial<FormatLocaleDefinition>;
|
|
34
|
-
};
|
|
35
|
-
export type RoutesMap = Record<string, RouteConfig>;
|
|
36
|
-
export type FileLoader = (path: string) => Promise<string>;
|
|
37
|
-
export type SyncFileLoader = (path: string) => string | undefined;
|
|
38
|
-
export type Config = {
|
|
39
|
-
env: Record<string, string>;
|
|
40
|
-
context?: ContextConfig;
|
|
41
|
-
routes: RoutesMap;
|
|
42
|
-
imageBaseUrl: string;
|
|
43
|
-
assetBaseUrl: string;
|
|
44
|
-
imageDefaults: Record<string, string>;
|
|
45
|
-
locale: string;
|
|
46
|
-
pathPrefix: string;
|
|
47
|
-
templatePath: string;
|
|
48
|
-
buildPath: string;
|
|
49
|
-
staticPath: string;
|
|
50
|
-
dates: DatesConfig;
|
|
51
|
-
usageStats: boolean;
|
|
52
|
-
htmlCompression?: {
|
|
53
|
-
enabled: boolean;
|
|
54
|
-
options?: Record<string, any>;
|
|
55
|
-
};
|
|
56
|
-
gzip: boolean;
|
|
57
|
-
numbers?: NumbersConfig;
|
|
58
|
-
locales?: Record<string, {
|
|
59
|
-
pathPrefix: string;
|
|
60
|
-
dates?: DatesConfig;
|
|
61
|
-
numbers?: NumbersConfig;
|
|
62
|
-
}>;
|
|
63
|
-
};
|
|
64
|
-
export declare function prepareConfig(config: Partial<Config>, envConfig?: Partial<Config>): Config;
|
|
65
|
-
export declare function loadConfig(fileLoader: FileLoader, configFilePath?: string, envConfig?: Partial<Config>): Promise<Config>;
|
|
66
|
-
export declare function localizeConfig(config: Config, localeStr: string): Config;
|
|
67
|
-
export type RouteInfo = {
|
|
68
|
-
routeName: string;
|
|
69
|
-
path: string;
|
|
70
|
-
isPaginated: boolean;
|
|
71
|
-
};
|
|
72
|
-
export type RouteQuery = {
|
|
73
|
-
filePath: string;
|
|
74
|
-
} & RouteInfo;
|
|
75
|
-
export declare function isGraphQLQueryConfig(x: ContextConfig): x is GraphQLQueryConfig;
|
|
76
|
-
export declare function getGraphQLQueries(config: Pick<Config, 'routes' | 'context'>): RouteQuery[];
|
package/dist/config.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import yaml from 'js-yaml';
|
|
2
|
-
import { jVar } from 'json-variables';
|
|
3
|
-
import flatten from 'lodash/flatten.js';
|
|
4
|
-
import forEach from 'lodash/forEach.js';
|
|
5
|
-
import merge from 'lodash/merge.js';
|
|
6
|
-
export function prepareConfig(config, envConfig) {
|
|
7
|
-
const combined = merge({
|
|
8
|
-
env: {},
|
|
9
|
-
context: {},
|
|
10
|
-
routes: {},
|
|
11
|
-
imageBaseUrl: 'https://images.takeshape.io',
|
|
12
|
-
assetBaseUrl: 'https://assets.takeshape.io',
|
|
13
|
-
imageDefaults: { auto: 'compress,format' },
|
|
14
|
-
locale: 'en-us',
|
|
15
|
-
pathPrefix: '',
|
|
16
|
-
templatePath: 'templates',
|
|
17
|
-
buildPath: 'build',
|
|
18
|
-
staticPath: 'static',
|
|
19
|
-
dates: {
|
|
20
|
-
tz: 'America/New_York',
|
|
21
|
-
format: 'LLL'
|
|
22
|
-
},
|
|
23
|
-
usageStats: false,
|
|
24
|
-
gzip: false
|
|
25
|
-
}, config, envConfig);
|
|
26
|
-
return jVar(combined, { heads: '${', tails: '}' });
|
|
27
|
-
}
|
|
28
|
-
export async function loadConfig(fileLoader, configFilePath, envConfig) {
|
|
29
|
-
const config = yaml.load(await fileLoader(configFilePath ?? 'tsg.yml'));
|
|
30
|
-
return prepareConfig(config, envConfig);
|
|
31
|
-
}
|
|
32
|
-
export function localizeConfig(config, localeStr) {
|
|
33
|
-
if (!config.locales?.[localeStr]) {
|
|
34
|
-
throw new Error(`Locale "${localeStr}" is not configured `);
|
|
35
|
-
}
|
|
36
|
-
const locale = config.locales[localeStr];
|
|
37
|
-
return {
|
|
38
|
-
...config,
|
|
39
|
-
pathPrefix: locale.pathPrefix,
|
|
40
|
-
locale: localeStr,
|
|
41
|
-
dates: { ...config.dates, ...locale.dates },
|
|
42
|
-
numbers: { ...config.numbers, ...locale.numbers }
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
function isGraphQLPath(path) {
|
|
46
|
-
return path.endsWith('.graphql') || path.endsWith('.gql');
|
|
47
|
-
}
|
|
48
|
-
export function isGraphQLQueryConfig(x) {
|
|
49
|
-
return typeof x === 'object' && typeof x.query === 'string' && isGraphQLPath(x.query);
|
|
50
|
-
}
|
|
51
|
-
function getContextGraphQLQueries(context, info) {
|
|
52
|
-
if (typeof context === 'string' && isGraphQLPath(context)) {
|
|
53
|
-
return [
|
|
54
|
-
{
|
|
55
|
-
filePath: context,
|
|
56
|
-
...info
|
|
57
|
-
}
|
|
58
|
-
];
|
|
59
|
-
}
|
|
60
|
-
if (typeof context === 'object') {
|
|
61
|
-
if (isGraphQLQueryConfig(context)) {
|
|
62
|
-
return [
|
|
63
|
-
{
|
|
64
|
-
filePath: context.query,
|
|
65
|
-
...info
|
|
66
|
-
}
|
|
67
|
-
];
|
|
68
|
-
}
|
|
69
|
-
const result = [];
|
|
70
|
-
forEach(context, (value) => {
|
|
71
|
-
Array.prototype.push.apply(result, getContextGraphQLQueries(value, info));
|
|
72
|
-
});
|
|
73
|
-
return result;
|
|
74
|
-
}
|
|
75
|
-
return [];
|
|
76
|
-
}
|
|
77
|
-
export function getGraphQLQueries(config) {
|
|
78
|
-
const { context, routes } = config;
|
|
79
|
-
const routeQueries = flatten(Object.keys(routes).map((routeName) => {
|
|
80
|
-
const route = routes[routeName];
|
|
81
|
-
const results = route.context
|
|
82
|
-
? getContextGraphQLQueries(route.context, {
|
|
83
|
-
routeName,
|
|
84
|
-
path: route.path,
|
|
85
|
-
isPaginated: false
|
|
86
|
-
})
|
|
87
|
-
: [];
|
|
88
|
-
if (route.paginate?.data) {
|
|
89
|
-
const filePath = isGraphQLQueryConfig(route.paginate.data) ? route.paginate.data.query : route.paginate.data;
|
|
90
|
-
results.push({
|
|
91
|
-
routeName,
|
|
92
|
-
filePath,
|
|
93
|
-
path: route.path,
|
|
94
|
-
isPaginated: true
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
return results;
|
|
98
|
-
}));
|
|
99
|
-
return context
|
|
100
|
-
? getContextGraphQLQueries(context, {
|
|
101
|
-
routeName: '*',
|
|
102
|
-
path: '*',
|
|
103
|
-
isPaginated: false
|
|
104
|
-
}).concat(routeQueries)
|
|
105
|
-
: routeQueries;
|
|
106
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { formatLocation } from "./formatting.js";
|
|
2
|
-
function ensureArray(obj) {
|
|
3
|
-
return Array.isArray(obj) ? obj : [obj];
|
|
4
|
-
}
|
|
5
|
-
function formatError(error) {
|
|
6
|
-
const locations = error.locations ? error.locations.map(formatLocation).join(' ') : '';
|
|
7
|
-
return `${locations} ${error.message}`;
|
|
8
|
-
}
|
|
9
|
-
function addErrorDetail(message, errors) {
|
|
10
|
-
const detail = errors ? ensureArray(errors).map(formatError).join('\n') : '';
|
|
11
|
-
return `${message}:\n${detail}`;
|
|
12
|
-
}
|
|
13
|
-
export default class GraphQLError extends Error {
|
|
14
|
-
errors;
|
|
15
|
-
originalMessage;
|
|
16
|
-
constructor(message, errors) {
|
|
17
|
-
super(addErrorDetail(message, errors));
|
|
18
|
-
this.errors = errors;
|
|
19
|
-
this.originalMessage = message;
|
|
20
|
-
this.name = 'GraphQLError';
|
|
21
|
-
}
|
|
22
|
-
}
|
package/dist/errors/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import GraphQLError from './graphql-error.ts';
|
|
2
|
-
import PaginationError from './pagination-error.ts';
|
|
3
|
-
import TemplateRenderError from './template-render-error.ts';
|
|
4
|
-
export declare const isSSGError: (error: Error) => boolean;
|
|
5
|
-
export { PaginationError, GraphQLError, TemplateRenderError };
|
package/dist/errors/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import GraphQLError from "./graphql-error.js";
|
|
2
|
-
import PaginationError from "./pagination-error.js";
|
|
3
|
-
import TemplateRenderError from "./template-render-error.js";
|
|
4
|
-
export const isSSGError = (error) => error instanceof PaginationError || error instanceof GraphQLError || error instanceof TemplateRenderError;
|
|
5
|
-
export { PaginationError, GraphQLError, TemplateRenderError };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { formatLocation } from "./formatting.js";
|
|
2
|
-
function formatError(message, location) {
|
|
3
|
-
const locationStr = formatLocation(location);
|
|
4
|
-
return location ? `${location.file}:\n${locationStr}${locationStr ? ' ' : ''}${message}` : message;
|
|
5
|
-
}
|
|
6
|
-
export default class TemplateRenderError extends Error {
|
|
7
|
-
constructor(message, location) {
|
|
8
|
-
super(formatError(message, location));
|
|
9
|
-
this.name = 'TemplateRenderError';
|
|
10
|
-
}
|
|
11
|
-
}
|
package/dist/files.d.ts
DELETED
package/dist/files.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import fse from 'fs-extra';
|
|
3
|
-
export function createFileSystemLoader(basePath) {
|
|
4
|
-
return async (filePath) => fse.readFile(path.join(basePath, filePath), 'utf8');
|
|
5
|
-
}
|
|
6
|
-
export function createSyncFileSystemLoader(basePath) {
|
|
7
|
-
return (fileName) => {
|
|
8
|
-
const filePath = path.join(basePath, fileName);
|
|
9
|
-
return fse.existsSync(filePath) ? fse.readFileSync(filePath, 'utf8') : undefined;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function codeFilter(value: any, languageString: string): any;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { highlightCode, isLanguageSupported } from '@takeshape/prism';
|
|
2
|
-
import { runtime } from '@takeshape/vm-nunjucks';
|
|
3
|
-
const { SafeString } = runtime;
|
|
4
|
-
export default function codeFilter(value, languageString) {
|
|
5
|
-
if (isLanguageSupported(languageString)) {
|
|
6
|
-
const cssClass = `"language-${languageString}"`;
|
|
7
|
-
const openingTags = `<pre class=${cssClass}><code class=${cssClass}>`;
|
|
8
|
-
const closingTags = '</code></pre>';
|
|
9
|
-
const highlightedCode = highlightCode(value, languageString);
|
|
10
|
-
return new SafeString(openingTags + highlightedCode + closingTags);
|
|
11
|
-
}
|
|
12
|
-
return value;
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function createAssetFilter(baseUrl: string): (path: string) => string;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import moment from 'moment-timezone';
|
|
2
|
-
export default function createDateFilter({ dates, locale: defaultLocale }) {
|
|
3
|
-
return (raw, options = {}) => {
|
|
4
|
-
if (typeof options === 'string') {
|
|
5
|
-
options = { format: options };
|
|
6
|
-
}
|
|
7
|
-
const { format = dates.format, tz = dates.tz, locale = defaultLocale } = options;
|
|
8
|
-
const date = moment.utc(raw).tz(tz);
|
|
9
|
-
date.locale(locale);
|
|
10
|
-
return date.format(format);
|
|
11
|
-
};
|
|
12
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { type FormatLocaleDefinition } from 'd3-format';
|
|
2
|
-
import type { Config } from '../config.ts';
|
|
3
|
-
export default function createNumberFilter({ numbers, locale }: Pick<Config, 'numbers' | 'locale'>): (value: number | string, formatStr?: string, config?: Partial<FormatLocaleDefinition>) => string;
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { formatLocale } from 'd3-format';
|
|
2
|
-
import arAE from 'd3-format/locale/ar-AE.json' with { type: 'json' };
|
|
3
|
-
import arBH from 'd3-format/locale/ar-BH.json' with { type: 'json' };
|
|
4
|
-
import arDJ from 'd3-format/locale/ar-DJ.json' with { type: 'json' };
|
|
5
|
-
import arDZ from 'd3-format/locale/ar-DZ.json' with { type: 'json' };
|
|
6
|
-
import arEG from 'd3-format/locale/ar-EG.json' with { type: 'json' };
|
|
7
|
-
import arEH from 'd3-format/locale/ar-EH.json' with { type: 'json' };
|
|
8
|
-
import arER from 'd3-format/locale/ar-ER.json' with { type: 'json' };
|
|
9
|
-
import arIL from 'd3-format/locale/ar-IL.json' with { type: 'json' };
|
|
10
|
-
import arIQ from 'd3-format/locale/ar-IQ.json' with { type: 'json' };
|
|
11
|
-
import arJO from 'd3-format/locale/ar-JO.json' with { type: 'json' };
|
|
12
|
-
import arKM from 'd3-format/locale/ar-KM.json' with { type: 'json' };
|
|
13
|
-
import arKW from 'd3-format/locale/ar-KW.json' with { type: 'json' };
|
|
14
|
-
import arLB from 'd3-format/locale/ar-LB.json' with { type: 'json' };
|
|
15
|
-
import arLY from 'd3-format/locale/ar-LY.json' with { type: 'json' };
|
|
16
|
-
import arMA from 'd3-format/locale/ar-MA.json' with { type: 'json' };
|
|
17
|
-
import arMR from 'd3-format/locale/ar-MR.json' with { type: 'json' };
|
|
18
|
-
import arOM from 'd3-format/locale/ar-OM.json' with { type: 'json' };
|
|
19
|
-
import arPS from 'd3-format/locale/ar-PS.json' with { type: 'json' };
|
|
20
|
-
import arQA from 'd3-format/locale/ar-QA.json' with { type: 'json' };
|
|
21
|
-
import arSA from 'd3-format/locale/ar-SA.json' with { type: 'json' };
|
|
22
|
-
import arSD from 'd3-format/locale/ar-SD.json' with { type: 'json' };
|
|
23
|
-
import arSO from 'd3-format/locale/ar-SO.json' with { type: 'json' };
|
|
24
|
-
import arSS from 'd3-format/locale/ar-SS.json' with { type: 'json' };
|
|
25
|
-
import arSY from 'd3-format/locale/ar-SY.json' with { type: 'json' };
|
|
26
|
-
import arTD from 'd3-format/locale/ar-TD.json' with { type: 'json' };
|
|
27
|
-
import arTN from 'd3-format/locale/ar-TN.json' with { type: 'json' };
|
|
28
|
-
import arYE from 'd3-format/locale/ar-YE.json' with { type: 'json' };
|
|
29
|
-
import caES from 'd3-format/locale/ca-ES.json' with { type: 'json' };
|
|
30
|
-
import csCZ from 'd3-format/locale/cs-CZ.json' with { type: 'json' };
|
|
31
|
-
import deCH from 'd3-format/locale/de-CH.json' with { type: 'json' };
|
|
32
|
-
import deDE from 'd3-format/locale/de-DE.json' with { type: 'json' };
|
|
33
|
-
import enCA from 'd3-format/locale/en-CA.json' with { type: 'json' };
|
|
34
|
-
import enGB from 'd3-format/locale/en-GB.json' with { type: 'json' };
|
|
35
|
-
import enIN from 'd3-format/locale/en-IN.json' with { type: 'json' };
|
|
36
|
-
import enUS from 'd3-format/locale/en-US.json' with { type: 'json' };
|
|
37
|
-
import esES from 'd3-format/locale/es-ES.json' with { type: 'json' };
|
|
38
|
-
import esMX from 'd3-format/locale/es-MX.json' with { type: 'json' };
|
|
39
|
-
import fiFI from 'd3-format/locale/fi-FI.json' with { type: 'json' };
|
|
40
|
-
import frCA from 'd3-format/locale/fr-CA.json' with { type: 'json' };
|
|
41
|
-
import frFR from 'd3-format/locale/fr-FR.json' with { type: 'json' };
|
|
42
|
-
import heIL from 'd3-format/locale/he-IL.json' with { type: 'json' };
|
|
43
|
-
import huHU from 'd3-format/locale/hu-HU.json' with { type: 'json' };
|
|
44
|
-
import itIT from 'd3-format/locale/it-IT.json' with { type: 'json' };
|
|
45
|
-
import jaJP from 'd3-format/locale/ja-JP.json' with { type: 'json' };
|
|
46
|
-
import koKR from 'd3-format/locale/ko-KR.json' with { type: 'json' };
|
|
47
|
-
import mkMK from 'd3-format/locale/mk-MK.json' with { type: 'json' };
|
|
48
|
-
import nlNL from 'd3-format/locale/nl-NL.json' with { type: 'json' };
|
|
49
|
-
import plPL from 'd3-format/locale/pl-PL.json' with { type: 'json' };
|
|
50
|
-
import ptBR from 'd3-format/locale/pt-BR.json' with { type: 'json' };
|
|
51
|
-
import ruRU from 'd3-format/locale/ru-RU.json' with { type: 'json' };
|
|
52
|
-
import svSE from 'd3-format/locale/sv-SE.json' with { type: 'json' };
|
|
53
|
-
import ukUA from 'd3-format/locale/uk-UA.json' with { type: 'json' };
|
|
54
|
-
import zhCN from 'd3-format/locale/zh-CN.json' with { type: 'json' };
|
|
55
|
-
const locales = {
|
|
56
|
-
'ar-ae': arAE,
|
|
57
|
-
'ar-bh': arBH,
|
|
58
|
-
'ar-dj': arDJ,
|
|
59
|
-
'ar-dz': arDZ,
|
|
60
|
-
'ar-eg': arEG,
|
|
61
|
-
'ar-eh': arEH,
|
|
62
|
-
'ar-er': arER,
|
|
63
|
-
'ar-il': arIL,
|
|
64
|
-
'ar-iq': arIQ,
|
|
65
|
-
'ar-jo': arJO,
|
|
66
|
-
'ar-km': arKM,
|
|
67
|
-
'ar-kw': arKW,
|
|
68
|
-
'ar-lb': arLB,
|
|
69
|
-
'ar-ly': arLY,
|
|
70
|
-
'ar-ma': arMA,
|
|
71
|
-
'ar-mr': arMR,
|
|
72
|
-
'ar-om': arOM,
|
|
73
|
-
'ar-ps': arPS,
|
|
74
|
-
'ar-qa': arQA,
|
|
75
|
-
'ar-sa': arSA,
|
|
76
|
-
'ar-sd': arSD,
|
|
77
|
-
'ar-so': arSO,
|
|
78
|
-
'ar-ss': arSS,
|
|
79
|
-
'ar-sy': arSY,
|
|
80
|
-
'ar-td': arTD,
|
|
81
|
-
'ar-tn': arTN,
|
|
82
|
-
'ar-ye': arYE,
|
|
83
|
-
'ca-es': caES,
|
|
84
|
-
'cs-cz': csCZ,
|
|
85
|
-
'de-ch': deCH,
|
|
86
|
-
'de-de': deDE,
|
|
87
|
-
'en-ca': enCA,
|
|
88
|
-
'en-gb': enGB,
|
|
89
|
-
'en-in': enIN,
|
|
90
|
-
'en-us': enUS,
|
|
91
|
-
'es-es': esES,
|
|
92
|
-
'es-mx': esMX,
|
|
93
|
-
'fi-fi': fiFI,
|
|
94
|
-
'fr-ca': frCA,
|
|
95
|
-
'fr-fr': frFR,
|
|
96
|
-
'he-il': heIL,
|
|
97
|
-
'hu-hu': huHU,
|
|
98
|
-
'it-it': itIT,
|
|
99
|
-
'ja-jp': jaJP,
|
|
100
|
-
'ko-kr': koKR,
|
|
101
|
-
'mk-mk': mkMK,
|
|
102
|
-
'nl-nl': nlNL,
|
|
103
|
-
'pl-pl': plPL,
|
|
104
|
-
'pt-br': ptBR,
|
|
105
|
-
'ru-ru': ruRU,
|
|
106
|
-
'sv-se': svSE,
|
|
107
|
-
'uk-ua': ukUA,
|
|
108
|
-
'zh-cn': zhCN
|
|
109
|
-
};
|
|
110
|
-
export default function createNumberFilter({ numbers, locale }) {
|
|
111
|
-
return (value, formatStr, config) => {
|
|
112
|
-
const localeSettings = {
|
|
113
|
-
...(locales[locale.toLowerCase()] || enUS),
|
|
114
|
-
...numbers?.config,
|
|
115
|
-
...config
|
|
116
|
-
};
|
|
117
|
-
const format = formatStr ? formatStr : numbers?.format ? numbers.format : ',';
|
|
118
|
-
return formatLocale(localeSettings).format(format)(value);
|
|
119
|
-
};
|
|
120
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { formatPath } from '@takeshape/routing';
|
|
2
|
-
import get from 'lodash/get.js';
|
|
3
|
-
import { joinPath } from "../paths.js";
|
|
4
|
-
import { generateWarning } from "../stats.js";
|
|
5
|
-
export default function createRouteFilter(config, stats) {
|
|
6
|
-
return function (obj, routeName) {
|
|
7
|
-
const route = get(config.routes, routeName);
|
|
8
|
-
let path;
|
|
9
|
-
if (route?.path) {
|
|
10
|
-
const pathResult = formatPath(route.path, obj);
|
|
11
|
-
path = joinPath(config.pathPrefix, pathResult.path);
|
|
12
|
-
if (pathResult.warnings.length) {
|
|
13
|
-
const currentPath = this.lookup('currentPath');
|
|
14
|
-
for (const variable of pathResult.warnings) {
|
|
15
|
-
generateWarning(stats, 'route-filter', `${currentPath} - failed to create '${routeName}' page - :${variable} resolves to undefined`);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
path = '#';
|
|
21
|
-
}
|
|
22
|
-
return path;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function markdownFilter(md: string): string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function pluralizeFilter(word: string, count?: number, inclusive?: boolean): string;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Config, RouteConfig } from '../config.ts';
|
|
2
|
-
import type { Data } from '../types.ts';
|
|
3
|
-
import type { PathItemContext } from './types.ts';
|
|
4
|
-
export declare function combineContext(env: Config['env'], globalContext: Data, route: RouteConfig, routeContext: Data): Data;
|
|
5
|
-
export type GetListPageContext = (items: Data[], pageNumber: number, routeContext: Data) => Data;
|
|
6
|
-
export declare const getListPageContext: GetListPageContext;
|
|
7
|
-
export type GetItemContext = (route: RouteConfig, context: Data, { current, previous, next }: PathItemContext) => Data;
|
|
8
|
-
export declare const getItemContext: GetItemContext;
|
package/dist/generate/context.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { formatPath } from '@takeshape/routing';
|
|
2
|
-
export function combineContext(env, globalContext, route, routeContext) {
|
|
3
|
-
return {
|
|
4
|
-
...globalContext,
|
|
5
|
-
...routeContext,
|
|
6
|
-
global: globalContext,
|
|
7
|
-
env,
|
|
8
|
-
environmentVariables: env, // DEPRECATE NEXT MAJOR VERSION
|
|
9
|
-
currentPath: route.path
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export const getListPageContext = (items, pageNumber, routeContext) => {
|
|
13
|
-
const { route, context, totalPages } = routeContext;
|
|
14
|
-
const { paginate } = route;
|
|
15
|
-
let currentPath;
|
|
16
|
-
if (paginate.firstPage && pageNumber === 1) {
|
|
17
|
-
currentPath = paginate.firstPage;
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
currentPath = formatPath(paginate.path, { num: pageNumber }).path;
|
|
21
|
-
}
|
|
22
|
-
const pageContext = {
|
|
23
|
-
currentPath,
|
|
24
|
-
items,
|
|
25
|
-
pagination: {
|
|
26
|
-
currentPage: pageNumber,
|
|
27
|
-
totalPages
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
return { ...context, ...pageContext };
|
|
31
|
-
};
|
|
32
|
-
export const getItemContext = (route, context, { current, previous, next }) => {
|
|
33
|
-
const itemContext = {
|
|
34
|
-
item: current.item,
|
|
35
|
-
currentPath: current.path
|
|
36
|
-
};
|
|
37
|
-
if (route.paginate?.itemName) {
|
|
38
|
-
itemContext[route.paginate.itemName] = current.item;
|
|
39
|
-
}
|
|
40
|
-
if (previous) {
|
|
41
|
-
itemContext.previousItem = previous.item;
|
|
42
|
-
itemContext.previousPath = previous.path;
|
|
43
|
-
}
|
|
44
|
-
if (next) {
|
|
45
|
-
itemContext.nextItem = next.item;
|
|
46
|
-
itemContext.nextPath = next.path;
|
|
47
|
-
}
|
|
48
|
-
return { ...context, ...itemContext };
|
|
49
|
-
};
|