@plone/volto 16.14.0 → 17.0.0-alpha.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.
@@ -48,7 +48,9 @@ export function formatDate({
48
48
  : short_date_format;
49
49
 
50
50
  const formatter = new Intl.DateTimeFormat(locale, format);
51
- return formatToParts ? formatter.formatToParts(date) : formatter.format(date);
51
+ return formatToParts
52
+ ? formatter.formatToParts(date)
53
+ : formatter.format(date).replace('\u202F', ' ');
52
54
  }
53
55
 
54
56
  export function formatRelativeDate({
@@ -93,5 +95,5 @@ export function formatRelativeDate({
93
95
  ? ''
94
96
  : formatToParts
95
97
  ? formatter.formatToParts(v, tag)
96
- : formatter.format(v, tag); // use "now" ?
98
+ : formatter.format(v, tag).replace('\u202F', ' '); // use "now" ?
97
99
  }
@@ -192,6 +192,8 @@ describe('formatRelativeDate helper', () => {
192
192
  it('can use alternate style narrow', () => {
193
193
  const now = Date.now();
194
194
  const d = new Date(now + 3 * MONTH);
195
- expect(formatRelativeDate({ date: d, style: 'narrow' })).toBe('in 3 mo.');
195
+ expect(['in 3 mo.', 'in 3mo']).toContain(
196
+ formatRelativeDate({ date: d, style: 'narrow' }),
197
+ );
196
198
  });
197
199
  });
@@ -30,7 +30,6 @@ export {
30
30
  removeProtocol,
31
31
  URLUtils,
32
32
  } from '@plone/volto/helpers/Url/Url';
33
- export { generateSitemap } from '@plone/volto/helpers/Sitemap/Sitemap';
34
33
  export { generateRobots } from '@plone/volto/helpers/Robots/Robots';
35
34
  export {
36
35
  nestContent,
@@ -1,7 +1,9 @@
1
1
  const path = require('path');
2
2
 
3
3
  class RelativeResolverPlugin {
4
- constructor(registry) {
4
+ constructor(registry, source, target) {
5
+ this.source = source || 'resolve';
6
+ this.target = target || 'resolve';
5
7
  this.registry = registry;
6
8
  this.voltoPaths = Object.assign(
7
9
  { '@plone/volto/': `${registry.voltoPath}/src` },
@@ -33,24 +35,36 @@ class RelativeResolverPlugin {
33
35
  }
34
36
 
35
37
  apply(resolver) {
36
- resolver.plugin('resolve', (request, callback) => {
37
- if (
38
- request.request.startsWith('.') &&
39
- request.context &&
40
- request.context.issuer &&
41
- this.isAddon(request)
42
- ) {
43
- const normalizedResourceName = this.getResolvePath(request);
44
- const nextRequest = Object.assign({}, request, {
45
- request: normalizedResourceName,
46
- path: this.registry.projectRootPath,
47
- });
48
-
49
- resolver.doResolve('resolve', nextRequest, '', callback);
50
- } else {
51
- callback();
52
- }
53
- });
38
+ var target = resolver.ensureHook(this.target);
39
+ resolver
40
+ .getHook(this.source)
41
+ .tapAsync(
42
+ 'RelativeResolverPlugin',
43
+ (request, resolveContext, callback) => {
44
+ if (
45
+ request.request.startsWith('.') &&
46
+ request.context &&
47
+ request.context.issuer &&
48
+ this.isAddon(request)
49
+ ) {
50
+ const normalizedResourceName = this.getResolvePath(request);
51
+ const nextRequest = Object.assign({}, request, {
52
+ request: normalizedResourceName,
53
+ path: this.registry.projectRootPath,
54
+ });
55
+
56
+ return resolver.doResolve(
57
+ target,
58
+ nextRequest,
59
+ null,
60
+ resolveContext,
61
+ callback,
62
+ );
63
+ } else {
64
+ callback();
65
+ }
66
+ },
67
+ );
54
68
  }
55
69
  }
56
70
 
@@ -1,23 +1,34 @@
1
1
  const path = require('path');
2
2
 
3
3
  class RootResolverPlugin {
4
+ constructor(source, target) {
5
+ this.source = source || 'resolve';
6
+ this.target = target || 'resolve';
7
+ }
8
+
4
9
  apply(resolver) {
5
- resolver.plugin('resolve', function RelativeBackResolver(
6
- request,
7
- callback,
8
- ) {
9
- if (request.request.startsWith('~/../')) {
10
- const resourcePath = request.request.substr(5);
10
+ var target = resolver.ensureHook(this.target);
11
+ resolver
12
+ .getHook(this.source)
13
+ .tapAsync('RootResolverPlugin', (request, resolveContext, callback) => {
14
+ if (request.request.startsWith('~/../')) {
15
+ const resourcePath = request.request.substr(5);
11
16
 
12
- const nextRequest = Object.assign({}, request, {
13
- request: path.resolve(`./${resourcePath}`),
14
- });
17
+ const nextRequest = Object.assign({}, request, {
18
+ request: path.resolve(`./${resourcePath}`),
19
+ });
15
20
 
16
- resolver.doResolve('resolve', nextRequest, '', callback);
17
- } else {
18
- callback();
19
- }
20
- });
21
+ resolver.doResolve(
22
+ target,
23
+ nextRequest,
24
+ null,
25
+ resolveContext,
26
+ callback,
27
+ );
28
+ } else {
29
+ callback();
30
+ }
31
+ });
21
32
  }
22
33
  }
23
34
 
@@ -16,10 +16,17 @@ module.exports = {
16
16
  loader: 'svgo-loader',
17
17
  options: {
18
18
  plugins: [
19
- { removeTitle: true },
20
- { convertPathData: false },
21
- { removeUselessStrokeAndFill: true },
22
- { removeViewBox: false },
19
+ {
20
+ name: 'preset-default',
21
+ params: {
22
+ overrides: {
23
+ convertPathData: false,
24
+ removeViewBox: false,
25
+ },
26
+ },
27
+ },
28
+ 'removeTitle',
29
+ 'removeUselessStrokeAndFill',
23
30
  ],
24
31
  },
25
32
  },