@gouvfr/dsfr-roller 1.0.45 → 1.0.47
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 +2 -2
- package/src/page/body/edit.js +0 -1
- package/src/page/head/share.js +4 -2
- package/src/page/head/title.js +1 -1
- package/src/page/scripts/analytics-config.js +3 -2
- package/src/script/main/core/get-query.js +2 -1
- package/src/script/main/elements/search-bar/index.js +3 -2
- package/src/script/main/minisearch/index.js +10 -3
- package/src/style/home/_hero.scss +1 -0
- package/static/img/cover.png +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gouvfr/dsfr-roller",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.47",
|
|
4
4
|
"description": "Le module `dsfr-roller` permet de publier le site de documentation du Système de Design de l’État - DSFR",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Système de Design de l'État",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
],
|
|
57
57
|
"main": "./index.js",
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@gouvfr/dsfr-forge": "=1.0.
|
|
59
|
+
"@gouvfr/dsfr-forge": "=1.0.47",
|
|
60
60
|
"@gouvfr/dsfr-publisher": "npm:@gouvfr/dsfr@1.14.0",
|
|
61
61
|
"deepmerge": "^4.3.1",
|
|
62
62
|
"ejs": "^3.1.10",
|
package/src/page/body/edit.js
CHANGED
package/src/page/head/share.js
CHANGED
|
@@ -4,9 +4,9 @@ class Share extends Renderable {
|
|
|
4
4
|
constructor(data) {
|
|
5
5
|
super(data, 'share');
|
|
6
6
|
this._resource = data.resource || {};
|
|
7
|
-
this._title =
|
|
7
|
+
this._title = data.pageTitle || this._resource?.meta?.title;
|
|
8
8
|
this._description = data.description || this._resource?.meta?.description;
|
|
9
|
-
this._cover = data.cover ||
|
|
9
|
+
this._cover = data.cover || this._resource?.meta?.cover;
|
|
10
10
|
this._url = this._resource?.meta?.baseUrl + data.url;
|
|
11
11
|
this._locale = `${data.lang}_${data.lang.toUpperCase()}`;
|
|
12
12
|
}
|
|
@@ -18,6 +18,7 @@ class Share extends Renderable {
|
|
|
18
18
|
<meta property="og:title" content="${this._title}">
|
|
19
19
|
<meta property="og:description" content="${this._description}">
|
|
20
20
|
<meta property="og:image" content="${this._cover}">
|
|
21
|
+
<meta property="og:image:alt" content="${this._title}">
|
|
21
22
|
<meta property="og:type" content="website">
|
|
22
23
|
<meta property="og:url" content="${this._url}">
|
|
23
24
|
<meta property="og:locale" content="${this._locale}">
|
|
@@ -27,6 +28,7 @@ class Share extends Renderable {
|
|
|
27
28
|
<meta name="twitter:description" content="${this._description}">
|
|
28
29
|
<meta name="twitter:site" content="@gouvernementFR">
|
|
29
30
|
<meta name="twitter:image" content="${this._cover}">
|
|
31
|
+
<meta name="twitter:image:alt" content="${this._title}">
|
|
30
32
|
`;
|
|
31
33
|
}
|
|
32
34
|
}
|
package/src/page/head/title.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Renderable } from '../../core/renderable.js';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
const PRODUCTION_ENV = 'prod';
|
|
3
4
|
|
|
4
5
|
class AnalyticsConfig extends Renderable {
|
|
5
6
|
constructor (data) {
|
|
@@ -20,7 +21,7 @@ class AnalyticsConfig extends Renderable {
|
|
|
20
21
|
const env = JSON.parse(xhr.responseText);
|
|
21
22
|
const analytics = ${JSON.stringify(this._analytics).replace('"$(1)"', 'env.domain').replace('"$(2)"', 'env.env')};
|
|
22
23
|
const dsfr = { analytics };
|
|
23
|
-
if (env.env ===
|
|
24
|
+
if (env.env === PRODUCTION_ENV) {
|
|
24
25
|
dsfr.production = true;
|
|
25
26
|
}
|
|
26
27
|
window.dsfr = dsfr;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const paramsString = window.location.search;
|
|
2
2
|
const searchParams = new URLSearchParams(paramsString);
|
|
3
|
+
import { normalizeTerm } from '@gouvfr/dsfr-forge/src/html/normalize.js';
|
|
3
4
|
|
|
4
5
|
const getQuery = () => {
|
|
5
|
-
return searchParams.get('query');
|
|
6
|
+
return normalizeTerm(searchParams.get('query'));
|
|
6
7
|
};
|
|
7
8
|
|
|
8
9
|
const getCurrentPagination = () => {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Element } from '../../core/element.js';
|
|
2
2
|
import { ResultsDropdown } from './results/results-dropdown.js';
|
|
3
|
+
import { normalizeTerm } from '@gouvfr/dsfr-forge/src/html/normalize.js';
|
|
3
4
|
|
|
4
5
|
class SearchBar extends Element {
|
|
5
6
|
constructor (element) {
|
|
6
7
|
super(element, 'searchBar');
|
|
7
8
|
this._searchInput = this.element.querySelector('#search-input');
|
|
8
9
|
this._searchButton = this.element.querySelector('#search-button');
|
|
9
|
-
this._query = this._searchInput.value;
|
|
10
|
+
this._query = normalizeTerm(this._searchInput.value);
|
|
10
11
|
this._url = this._searchButton.getAttribute('data-href');
|
|
11
12
|
}
|
|
12
13
|
|
|
@@ -62,7 +63,7 @@ class SearchBar extends Element {
|
|
|
62
63
|
} else if (event.key === 'Escape') {
|
|
63
64
|
this._resultsDropdown.reset();
|
|
64
65
|
} else {
|
|
65
|
-
this.update(event.target.value);
|
|
66
|
+
this.update(normalizeTerm(event.target.value));
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import MiniSearch from 'minisearch';
|
|
2
|
+
import { normalizeTerm } from '@gouvfr/dsfr-forge/src/html/normalize.js';
|
|
2
3
|
|
|
3
4
|
const LOAD_OPTIONS = {
|
|
4
5
|
fields: ['title', 'keywords', 'summary', 'excerpt', 'text'],
|
|
@@ -6,18 +7,24 @@ const LOAD_OPTIONS = {
|
|
|
6
7
|
};
|
|
7
8
|
|
|
8
9
|
const SEARCH_OPTIONS = {
|
|
9
|
-
prefix: true,
|
|
10
10
|
boost: { title: 2.5, keywords: 2, summary: 1.5, text: 1 },
|
|
11
11
|
boostDocument: (documentId, query, storedFields) =>
|
|
12
12
|
storedFields?.boost ?? 1,
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const getOptions = (type) => {
|
|
16
|
+
const options = {
|
|
17
|
+
prefix: true,
|
|
18
|
+
fuzzy: 0.2,
|
|
19
|
+
processTerm: (term) => normalizeTerm(term.toLowerCase())
|
|
20
|
+
};
|
|
21
|
+
|
|
16
22
|
switch (type) {
|
|
17
23
|
case 'search':
|
|
18
|
-
return SEARCH_OPTIONS;
|
|
24
|
+
return { ...options, ...SEARCH_OPTIONS };
|
|
25
|
+
|
|
19
26
|
default:
|
|
20
|
-
return LOAD_OPTIONS;
|
|
27
|
+
return { ...options, ...LOAD_OPTIONS };
|
|
21
28
|
}
|
|
22
29
|
}
|
|
23
30
|
|
|
Binary file
|