notes-to-strapi-export-article-ai 1.0.11 → 1.0.13

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.
@@ -1,59 +1,93 @@
1
- name: Auto Deploy, install dependencies, increment version and push tag
1
+ name: Auto Deploy, install dependencies, increment version, push tag, and create release
2
2
 
3
3
  on:
4
- pull_request:
5
- branches: [ main ]
6
- types: [ closed ]
4
+ pull_request:
5
+ branches: [ main ]
6
+ types: [ closed ]
7
7
 
8
8
  jobs:
9
- publish:
10
- if: github.event.pull_request.merged == true
11
- runs-on: ubuntu-latest
12
- steps:
13
- - name: Checkout
14
- uses: actions/checkout@v4
15
- with:
16
- fetch-depth: 0
17
- token: ${{ secrets.GIT_TOKEN }}
18
- ref: 'main'
19
-
20
- - name: Configure Git
21
- run: |
22
- git config --local user.email "cinquin.andy@gmail.com"
23
- git config --local user.name "CINQUIN Andy"
24
-
25
- - name: Use Node.js
26
- uses: actions/setup-node@v4
27
- with:
28
- node-version: '20'
29
- registry-url: 'https://registry.npmjs.org'
30
-
31
- - name: Install Dependencies
32
- run: npm ci
33
-
34
- - name: Increment Package Version and Update Tag
35
- id: version-bump
36
- run: |
37
- git fetch --tags
38
- current_version=$(npm pkg get version | sed 's/"//g')
39
- echo "Current version: $current_version"
40
-
41
- new_version=$(npx semver -i patch $current_version)
42
- echo "New version: $new_version"
43
-
44
- while git rev-parse $new_version >/dev/null 2>&1; do
45
- new_version=$(npx semver -i patch $new_version)
46
- echo "Tag $new_version already exists. Trying next version..."
47
- done
48
-
49
- npm version $new_version --no-git-tag-version
50
- sed -i "s/\"version\": \".*\"/\"version\": \"$new_version\"/" manifest.json
51
- echo "version=$new_version" >> $GITHUB_OUTPUT
52
-
53
- - name: Commit and Push Version Update
54
- run: |
55
- git add package.json manifest.json
56
- git commit -m "chore(release): ${{ steps.version-bump.outputs.version }}"
57
- git tag ${{ steps.version-bump.outputs.version }}
58
- git push origin main --follow-tags
59
- git push origin refs/tags/${{ steps.version-bump.outputs.version }}
9
+ publish:
10
+ if: github.event.pull_request.merged == true
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Checkout
14
+ uses: actions/checkout@v4
15
+ with:
16
+ fetch-depth: 0
17
+ token: ${{ secrets.GIT_TOKEN }}
18
+ ref: 'main'
19
+
20
+ - name: Configure Git
21
+ run: |
22
+ git config --local user.email "cinquin.andy@gmail.com"
23
+ git config --local user.name "CINQUIN Andy"
24
+
25
+ - name: Use Node.js
26
+ uses: actions/setup-node@v4
27
+ with:
28
+ node-version: '20'
29
+ registry-url: 'https://registry.npmjs.org'
30
+
31
+ - name: Install Dependencies
32
+ run: npm ci
33
+
34
+ - name: Build TypeScript
35
+ run: npm run build
36
+
37
+ - name: Increment Package Version and Update Tag
38
+ id: version-bump
39
+ run: |
40
+ git fetch --tags
41
+ current_version=$(npm pkg get version | sed 's/"//g')
42
+ echo "Current version: $current_version"
43
+
44
+ new_version=$(npx semver -i patch $current_version)
45
+ echo "New version: $new_version"
46
+
47
+ while git rev-parse $new_version >/dev/null 2>&1; do
48
+ new_version=$(npx semver -i patch $new_version)
49
+ echo "Tag $new_version already exists. Trying next version..."
50
+ done
51
+
52
+ npm version $new_version --no-git-tag-version
53
+ sed -i "s/\"version\": \".*\"/\"version\": \"$new_version\"/" manifest.json
54
+ echo "version=$new_version" >> $GITHUB_OUTPUT
55
+
56
+ - name: Commit and Push Version Update
57
+ run: |
58
+ git add package.json manifest.json
59
+ git commit -m "chore(release): ${{ steps.version-bump.outputs.version }}"
60
+ git tag ${{ steps.version-bump.outputs.version }}
61
+ git push origin main --follow-tags
62
+ git push origin refs/tags/${{ steps.version-bump.outputs.version }}
63
+
64
+ - name: Create Release
65
+ id: create_release
66
+ uses: actions/create-release@v1
67
+ env:
68
+ GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
69
+ with:
70
+ tag_name: ${{ steps.version-bump.outputs.version }}
71
+ release_name: Release ${{ steps.version-bump.outputs.version }}
72
+ draft: false
73
+ prerelease: false
74
+
75
+ - name: Upload main.js to Release
76
+ uses: actions/upload-release-asset@v1
77
+ env:
78
+ GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
79
+ with:
80
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
81
+ asset_path: ./main.js
82
+ asset_name: main.js
83
+ asset_content_type: application/javascript
84
+
85
+ - name: Upload manifest.json to Release
86
+ uses: actions/upload-release-asset@v1
87
+ env:
88
+ GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
89
+ with:
90
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
91
+ asset_path: ./manifest.json
92
+ asset_name: manifest.json
93
+ asset_content_type: application/json
package/README.md CHANGED
@@ -43,29 +43,29 @@ To install Strapi Exporter, follow these steps (coming soon to the Obsidian plug
43
43
  To get started with Strapi Exporter, you'll need to configure the following settings:
44
44
 
45
45
  - **Strapi URL**: The URL of your Strapi instance (e.g., `https://your-strapi-url`).
46
- ![img.png](img.png)
46
+ ![img.png](images/img.png)
47
47
  - **Strapi API Token**: Your Strapi API token for authentication. You can create an API token in your Strapi admin panel under "Settings" > "API Tokens".
48
- ![img_1.png](img_1.png)
49
- ![img_2.png](img_2.png)
48
+ ![img_1.png](images/img_1.png)
49
+ ![img_2.png](images/img_2.png)
50
50
  - You need, at least, to have the following permissions:
51
51
  - article: create
52
52
  - upload: create
53
53
  - (you can also add full permissions, but it's not really recommended for security reasons)
54
- ![img_3.png](img_3.png)
54
+ ![img_3.png](images/img_3.png)
55
55
  - (the token in the screenshot is not valid, don't try to use it 😌)
56
56
  - **OpenAI API Key**: Your OpenAI API key for using GPT-3 to generate SEO-friendly content. You can get your API key from the [OpenAI website](https://platform.openai.com/account/api-keys).
57
- ![img_4.png](img_4.png)
57
+ ![img_4.png](images/img_4.png)
58
58
  - this key is needed to use the GPT-3 API, which is used to generate the content of the article
59
59
  - (it need to access to "Model capabilities" with "write" permission)
60
- ![img_5.png](img_5.png)
60
+ ![img_5.png](images/img_5.png)
61
61
  - (or with the "all" permission)
62
62
  - **JSON Template**: The JSON template for the article fields in Strapi. Customize this according to your Strapi content type structure. You can find the JSON template in your Strapi API documentation (Swagger).
63
- ![img_6.png](img_6.png)
63
+ ![img_6.png](images/img_6.png)
64
64
  - to get the JSON template, you can go to the documentation of your Strapi API, and copy the JSON template of the article creation
65
65
  - it should look like this: ``https://{api_url}/documentation/v1.0.0``
66
66
  - then, go to the article creation, and copy the JSON template
67
- ![img_7.png](img_7.png)
68
- ![img_8.png](img_8.png)
67
+ ![img_7.png](images/img_7.png)
68
+ ![img_8.png](images/img_8.png)
69
69
  - it should look like this for example:
70
70
  ```json
71
71
  {
@@ -147,7 +147,7 @@ To get started with Strapi Exporter, you'll need to configure the following sett
147
147
 
148
148
  1. Open a Markdown file in Obsidian.
149
149
  2. Click on the plugin's ribbon icon to start the magic.
150
- ![img_9.png](img_9.png)
150
+ ![img_9.png](images/img_9.png)
151
151
  3. Sit back and relax while Strapi Exporter does the heavy lifting:
152
152
  - 🖼️ Extracting and uploading images to Strapi
153
153
  - 🎨 Generating SEO-friendly alt text and captions for images
@@ -15,7 +15,7 @@ const context = await esbuild.context({
15
15
  banner: {
16
16
  js: banner,
17
17
  },
18
- entryPoints: ["main.ts"],
18
+ entryPoints: ["src/main.ts"],
19
19
  bundle: true,
20
20
  external: [
21
21
  "obsidian",
package/manifest.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "notes-to-strapi-export-article-ai",
3
3
  "name": "Strapi Exporter, Notes to Strapi article AI enhanced",
4
- "version": "1.0.11",
4
+ "version": "1.0.13",
5
5
  "minAppVersion": "1.5.0",
6
6
  "description": "Effortlessly export your 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.",
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.11",
3
+ "version": "1.0.13",
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": {
@@ -22,6 +22,7 @@
22
22
  "typescript": "5.4.3"
23
23
  },
24
24
  "dependencies": {
25
- "openai": "^4.0.0"
25
+ "openai": "^4.0.0",
26
+ "process": "^0.11.10"
26
27
  }
27
28
  }
@@ -0,0 +1,67 @@
1
+ import { StrapiExporterSettings } from './types/settings'
2
+
3
+ /**
4
+ * The default settings for the plugin
5
+ */
6
+ export const DEFAULT_STRAPI_EXPORTER_SETTINGS: StrapiExporterSettings = {
7
+ strapiUrl: '',
8
+ strapiApiToken: '',
9
+ openaiApiKey: '',
10
+ jsonTemplate: `{
11
+ "data": {
12
+ "title": "string",
13
+ "seo_title": "string",
14
+ "seo_description": "string",
15
+ "slug": "string",
16
+ "excerpt": "string",
17
+ "links": [
18
+ {
19
+ "id": "number",
20
+ "label": "string",
21
+ "url": "string"
22
+ }
23
+ ],
24
+ "subtitle": "string",
25
+ "type": "string",
26
+ "rank": "number",
27
+ "tags": [
28
+ {
29
+ "id": "number",
30
+ "name": "string"
31
+ }
32
+ ],
33
+ "locale": "string"
34
+ }
35
+ }`,
36
+ jsonTemplateDescription: `{
37
+ "data": {
38
+ "title": "Title of the item, as a short string",
39
+ "seo_title": "SEO optimized title, as a short string",
40
+ "seo_description": "SEO optimized description, as a short string",
41
+ "slug": "URL-friendly string derived from the title",
42
+ "excerpt": "A short preview or snippet from the content",
43
+ "links": "Array of related links with ID, label, and URL",
44
+ "subtitle": "Subtitle or secondary title, as a short string",
45
+ "type": "Category or type of the item, as a short string",
46
+ "rank": "Numerical ranking or order priority, as a number",
47
+ "tags": "Array of associated tags with ID and name",
48
+ "locale": "Locale or language code, as a short string"
49
+ }
50
+ }`,
51
+ strapiArticleCreateUrl: '',
52
+ strapiContentAttributeName: '',
53
+ additionalPrompt: '',
54
+ enableAdditionalApiCall: false,
55
+ additionalJsonTemplate: '',
56
+ additionalJsonTemplateDescription: '',
57
+ additionalUrl: '',
58
+ additionalContentAttributeName: '',
59
+ mainButtonImageEnabled: false,
60
+ mainButtonGalleryEnabled: false,
61
+ additionalButtonImageEnabled: false,
62
+ additionalButtonGalleryEnabled: false,
63
+ mainImageFullPathProperty: '',
64
+ mainGalleryFullPathProperty: '',
65
+ additionalImageFullPathProperty: '',
66
+ additionalGalleryFullPathProperty: '',
67
+ }
package/src/main.ts ADDED
@@ -0,0 +1,61 @@
1
+ import { Plugin } from 'obsidian'
2
+ import { StrapiExporterSettingTab } from './settings'
3
+ import { DEFAULT_STRAPI_EXPORTER_SETTINGS } from './constants'
4
+ import { processMarkdownContent } from './utils/image-processor'
5
+ import { StrapiExporterSettings } from './types/settings'
6
+
7
+ export default class StrapiExporterPlugin extends Plugin {
8
+ settings: StrapiExporterSettings
9
+
10
+ async onload() {
11
+ await this.loadSettings()
12
+
13
+ // Add ribbon icons and event listeners
14
+ /**
15
+ * Add a ribbon icon to the Markdown view (the little icon on the left side bar)
16
+ */
17
+ const ribbonIconEl = this.addRibbonIcon(
18
+ 'upload',
19
+ 'Upload images to Strapi and update links in Markdown content, then generate article content using OpenAI',
20
+ async (evt: MouseEvent) => {
21
+ await this.processMarkdownContent()
22
+ }
23
+ )
24
+ ribbonIconEl.addClass('strapi-exporter-ribbon-class')
25
+
26
+ /**
27
+ * Add a ribbon icon based on the settings (if enabled)
28
+ */
29
+ if (this.settings.enableAdditionalApiCall) {
30
+ const additionalRibbonIconEl = this.addRibbonIcon(
31
+ 'link',
32
+ 'Upload images to Strapi and update links in Markdown content, then generate additional content using OpenAI',
33
+ async (evt: MouseEvent) => {
34
+ await this.processMarkdownContent(true)
35
+ }
36
+ )
37
+ additionalRibbonIconEl.addClass('strapi-exporter-additional-ribbon-class')
38
+ }
39
+
40
+ this.addSettingTab(new StrapiExporterSettingTab(this.app, this))
41
+ }
42
+
43
+ onunload() {}
44
+
45
+ async loadSettings() {
46
+ this.settings = Object.assign(
47
+ {},
48
+ DEFAULT_STRAPI_EXPORTER_SETTINGS,
49
+ await this.loadData()
50
+ )
51
+ }
52
+
53
+ async saveSettings() {
54
+ await this.saveData(this.settings)
55
+ }
56
+
57
+ async processMarkdownContent(useAdditionalCallAPI = false) {
58
+ // Call processMarkdownContent from image-processor.ts
59
+ await processMarkdownContent(this.app, this.settings, useAdditionalCallAPI)
60
+ }
61
+ }