osuny-owl 2.0.0 → 2.1.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/package.json +1 -1
- package/src/builders/content.js +60 -0
- package/src/builders/index.js +9 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "osuny-owl",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Osuny Owl is an object that can go talk to the Osuny API, to create post or other osuny components from a large amount of data",
|
|
5
5
|
"keywords": ["osuny", "api"],
|
|
6
6
|
"license": "GPL-3.0",
|
package/src/builders/content.js
CHANGED
|
@@ -49,6 +49,66 @@ export function createProject(title, migration_identifier, year, blocks, locale
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Ajoute une localisation à un post existant
|
|
54
|
+
*
|
|
55
|
+
* @param {Object} post - Le post existant (créé avec createPost)
|
|
56
|
+
* @param {string} locale - Code de la locale (ex: "en", "es", "de")
|
|
57
|
+
* @param {string} title - Titre dans la nouvelle locale
|
|
58
|
+
* @param {Array} blocks - Blocs dans la nouvelle locale
|
|
59
|
+
* @param {string} summary - Résumé dans la nouvelle locale (optionnel)
|
|
60
|
+
* @param {Date} crea_dt - Date de création (optionnel)
|
|
61
|
+
* @returns {Object} Le post modifié avec la nouvelle locale
|
|
62
|
+
*/
|
|
63
|
+
export function addLocaleToPost(post, locale, title, blocks, summary = "", crea_dt = undefined) {
|
|
64
|
+
// Ajouter la nouvelle locale dans l'objet localizations
|
|
65
|
+
post.localizations[locale] = {
|
|
66
|
+
"id": undefined,
|
|
67
|
+
"migration_identifier": post.migration_identifier + `_${locale}`,
|
|
68
|
+
"title": title,
|
|
69
|
+
"featured_image": undefined,
|
|
70
|
+
"pinned": false,
|
|
71
|
+
"published": true,
|
|
72
|
+
"published_at": crea_dt,
|
|
73
|
+
"slug": slugify(title),
|
|
74
|
+
"summary": summary,
|
|
75
|
+
"blocks": blocks,
|
|
76
|
+
"created_at": crea_dt
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return post;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Ajoute une localisation à un projet existant
|
|
84
|
+
*
|
|
85
|
+
* @param {Object} project - Le projet existant (créé avec createProject)
|
|
86
|
+
* @param {string} locale - Code de la locale (ex: "en", "es", "de")
|
|
87
|
+
* @param {string} title - Titre dans la nouvelle locale
|
|
88
|
+
* @param {Array} blocks - Blocs dans la nouvelle locale
|
|
89
|
+
* @param {string} summary - Résumé dans la nouvelle locale (optionnel)
|
|
90
|
+
* @param {Date} crea_dt - Date de création (optionnel)
|
|
91
|
+
* @returns {Object} Le projet modifié avec la nouvelle locale
|
|
92
|
+
*/
|
|
93
|
+
export function addLocaleToProject(project, locale, title, blocks, summary = "", crea_dt = undefined) {
|
|
94
|
+
// Ajouter la nouvelle locale dans l'objet localizations
|
|
95
|
+
project.localizations[locale] = {
|
|
96
|
+
"id": undefined,
|
|
97
|
+
"migration_identifier": project.migration_identifier + `_${locale}`,
|
|
98
|
+
"title": title,
|
|
99
|
+
"featured_image": undefined,
|
|
100
|
+
"pinned": false,
|
|
101
|
+
"published": true,
|
|
102
|
+
"published_at": crea_dt,
|
|
103
|
+
"slug": slugify(title),
|
|
104
|
+
"summary": summary,
|
|
105
|
+
"blocks": blocks,
|
|
106
|
+
"created_at": crea_dt
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
return project;
|
|
110
|
+
}
|
|
111
|
+
|
|
52
112
|
export function composePost(...osunyBlocks) {
|
|
53
113
|
let blocksArray = [];
|
|
54
114
|
osunyBlocks.forEach((el) => {
|
package/src/builders/index.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import * as blocks from './blocks/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createPost,
|
|
4
|
+
createProject,
|
|
5
|
+
composePost,
|
|
6
|
+
addLocaleToPost,
|
|
7
|
+
addLocaleToProject
|
|
8
|
+
} from './content.js';
|
|
3
9
|
import { slugify } from '../utils/slug.js';
|
|
4
10
|
|
|
5
11
|
export class OsunyUtility {
|
|
@@ -11,5 +17,7 @@ export class OsunyUtility {
|
|
|
11
17
|
static createPost = createPost;
|
|
12
18
|
static createProject = createProject;
|
|
13
19
|
static composePost = composePost;
|
|
20
|
+
static addLocaleToPost = addLocaleToPost;
|
|
21
|
+
static addLocaleToProject = addLocaleToProject;
|
|
14
22
|
static slugify = slugify;
|
|
15
23
|
}
|