notes-to-strapi-export-article-ai 1.0.29 → 1.0.30
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/manifest.json +1 -1
- package/package.json +1 -1
- package/src/utils/image-processor.ts +13 -11
- package/src/utils/strapi-uploader.ts +9 -11
- package/versions.json +2 -1
package/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "notes-to-strapi-export-article-ai",
|
|
3
3
|
"name": "Strapi Exporter AI",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.30",
|
|
5
5
|
"minAppVersion": "1.5.0",
|
|
6
6
|
"description": "Effortlessly export your notes to Strapi CMS with AI-powered handling and SEO optimization.",
|
|
7
7
|
"author": "Cinquin Andy",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "notes-to-strapi-export-article-ai",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.30",
|
|
4
4
|
"description": "Effortlessly export your Obsidian notes to Strapi CMS with AI-powered image handling and SEO optimization. Replace all the images in your notes by uploaded images in Strapi, and add SEO metadata to uploaded images.",
|
|
5
5
|
"main": "main.js",
|
|
6
6
|
"scripts": {
|
|
@@ -256,24 +256,26 @@ export async function processMarkdownContent(
|
|
|
256
256
|
|
|
257
257
|
new Notice('Article content generated successfully!')
|
|
258
258
|
try {
|
|
259
|
-
const response = await
|
|
260
|
-
|
|
259
|
+
const response = await fetch(
|
|
260
|
+
useAdditionalCallAPI
|
|
261
261
|
? settings.additionalUrl
|
|
262
262
|
: settings.strapiArticleCreateUrl,
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
263
|
+
{
|
|
264
|
+
method: 'POST',
|
|
265
|
+
headers: {
|
|
266
|
+
'Content-Type': 'application/json',
|
|
267
|
+
Authorization: `Bearer ${settings.strapiApiToken}`,
|
|
268
|
+
},
|
|
269
|
+
body: JSON.stringify(articleContent),
|
|
270
|
+
}
|
|
271
|
+
)
|
|
270
272
|
|
|
271
|
-
if (response.
|
|
273
|
+
if (response.ok) {
|
|
272
274
|
new Notice(
|
|
273
275
|
'Check your API content now, the article is created & uploaded! 🎉'
|
|
274
276
|
)
|
|
275
277
|
} else {
|
|
276
|
-
const errorData = await response.json
|
|
278
|
+
const errorData = await response.json()
|
|
277
279
|
new Notice(
|
|
278
280
|
`Failed to create article in Strapi. Error: ${errorData.error.message}`
|
|
279
281
|
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Notice } from 'obsidian'
|
|
1
|
+
import { Notice, requestUrl } from 'obsidian'
|
|
2
2
|
import { StrapiExporterSettings } from '../types/settings'
|
|
3
3
|
import { ImageBlob, ImageDescription } from '../types/image'
|
|
4
4
|
|
|
@@ -31,8 +31,7 @@ export async function uploadImagesToStrapi(
|
|
|
31
31
|
)
|
|
32
32
|
|
|
33
33
|
try {
|
|
34
|
-
const response = await
|
|
35
|
-
url: `${settings.strapiUrl}/api/upload`,
|
|
34
|
+
const response = await fetch(`${settings.strapiUrl}/api/upload`, {
|
|
36
35
|
method: 'POST',
|
|
37
36
|
headers: {
|
|
38
37
|
Authorization: `Bearer ${settings.strapiApiToken}`,
|
|
@@ -40,15 +39,15 @@ export async function uploadImagesToStrapi(
|
|
|
40
39
|
body: formData,
|
|
41
40
|
})
|
|
42
41
|
|
|
43
|
-
if (response.
|
|
44
|
-
const data = await response.json
|
|
42
|
+
if (response.ok) {
|
|
43
|
+
const data = await response.json()
|
|
45
44
|
uploadedImages[imageDescription.name] = {
|
|
46
45
|
url: data[0].url,
|
|
47
46
|
data: data[0],
|
|
48
47
|
id: data[0].id,
|
|
49
48
|
}
|
|
50
49
|
} else {
|
|
51
|
-
const errorData = await response.json
|
|
50
|
+
const errorData = await response.json()
|
|
52
51
|
new Notice(
|
|
53
52
|
`Failed to upload image: ${imageDescription.name}. Error: ${errorData.error.message}`
|
|
54
53
|
)
|
|
@@ -95,8 +94,7 @@ export async function uploadGalleryImagesToStrapi(
|
|
|
95
94
|
formData.append('files', imageBlob.blob, imageBlob.name)
|
|
96
95
|
|
|
97
96
|
try {
|
|
98
|
-
const response = await
|
|
99
|
-
url: `${settings.strapiUrl}/api/upload`,
|
|
97
|
+
const response = await fetch(`${settings.strapiUrl}/api/upload`, {
|
|
100
98
|
method: 'POST',
|
|
101
99
|
headers: {
|
|
102
100
|
Authorization: `Bearer ${settings.strapiApiToken}`,
|
|
@@ -104,15 +102,15 @@ export async function uploadGalleryImagesToStrapi(
|
|
|
104
102
|
body: formData,
|
|
105
103
|
})
|
|
106
104
|
|
|
107
|
-
if (response.
|
|
108
|
-
const data = await response.json
|
|
105
|
+
if (response.ok) {
|
|
106
|
+
const data = await response.json()
|
|
109
107
|
uploadedImages[imageBlob.name] = {
|
|
110
108
|
url: data[0].url,
|
|
111
109
|
id: data[0].id,
|
|
112
110
|
data: data[0],
|
|
113
111
|
}
|
|
114
112
|
} else {
|
|
115
|
-
const errorData = await response.json
|
|
113
|
+
const errorData = await response.json()
|
|
116
114
|
new Notice(
|
|
117
115
|
`Failed to upload gallery image: ${imageBlob.name}. Error: ${errorData.error.message}`
|
|
118
116
|
)
|