Skip to content

Commit 74d68c4

Browse files
committed
Update docs
1 parent 5d1947f commit 74d68c4

File tree

14 files changed

+409
-12
lines changed

14 files changed

+409
-12
lines changed

.frontmatter/database/mediaDb.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

content/changelog/v10.3.0.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,27 @@
22
title: Version 10.3.0 release notes
33
description: ""
44
date: 2024-08-12T14:16:11.167Z
5-
lastmod: 2024-08-13T08:15:59.698Z
5+
lastmod: 2024-08-13T11:38:26.429Z
66
slug: v10.3.0
77
fmContentType: changelog
88
---
99

10+
## GitHub Copilot integration
11+
12+
In the July 2024 release of Visual Studio Code, extension developers are able to make use of the GitHub Copilot's Large Language Model (LLM). Front Matter CMS took advantage of this feature to provide you with the ability to provide title, description, and taxonomy suggestions.
13+
14+
> **Important**: This feature is only available when you have the GitHub Copilot extension installed and a valid license.
15+
16+
For example, when creating new content when you have the GitHub Copilot extension installed, you will get title suggestions based on the provided title.
17+
18+
![Title suggestions provided by GitHub Copilot](/releases/v10.3.0/github-copilot-title-suggestions.webp)
19+
20+
For descriptions and tags, you will get a new field action button which allows you to generate suggestions based on the content.
21+
22+
![Trigger GitHub Copilot description suggestion](/releases/v10.3.0/github-copilot-description-suggestion.webp)
23+
24+
> **Info**: You can find more information about the GitHub Copilot integration in the [AI features](/docs/ai-features) documentation.
25+
1026
## Added open in VS Code button to the documentation
1127

1228
Inside the documentation, we have added a new button to open certain areas from Front Matter CMS directly in VS Code. This helps you to quickly navigate to the right place in your project.
@@ -27,6 +43,14 @@ The UI extensibility feature is now generally available, which means you do not
2743

2844
> **Info**: You can find more information about UI extensibility in the [UI extensibility](/docs/ui-extensibility) documentation.
2945
46+
### Field actions
47+
48+
You can now link custom actions to fields which allows you to populate a field with a value by executing a custom script.
49+
50+
![Custom field actions](/releases/v10.3.0/field-actions.webp)
51+
52+
> **Info**: You can find more information about field actions in the [field actions](/docs/content-creation/field-actions) documentation.
53+
3054
### Ability to copy metadata or delete media files
3155

3256
Our extensibility library has been extended with new actions which allow you to copy metadata or delete media files. This can be useful when you want to perform certain actions like for example convert a meda file to a different format and keep the metadata.
@@ -39,11 +63,19 @@ New actions:
3963

4064
> **Info**: You can find more information about these actions in the [media scripts](/docs/custom-actions/media-scripts) documentation.
4165
66+
## Documentation and API updates
67+
68+
As Vercel recently stoped its support for open-source projects, we had to move our documentation and API to different hosts.
69+
70+
The documentation is now hosted on [Netlify](https://www.netlify.com/), and the API is hosted on Azure Functions.
71+
72+
> **Important**: Get in touch with us if you have any issues accessing the documentation or the API.
73+
4274
## Related issues/enhancements
4375

4476
### ✨ New features
4577

46-
- [#823](https://github.com/estruyf/vscode-front-matter/issues/823): Integrated GitHub Copilot support for titles, descriptions, and tags
78+
- [#823](https://github.com/estruyf/vscode-front-matter/issues/823): Integrated GitHub Copilot support for titles, descriptions, and taxonomy field suggestions
4779
- [#824](https://github.com/estruyf/vscode-front-matter/issues/824): Added the ability to link custom actions to fields
4880

4981
### 🎨 Enhancements

content/docs/ai/index.md

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,59 @@ title: AI features
33
slug: ai-features
44
description: null
55
date: 2024-08-13T07:26:50.054Z
6-
lastmod: 2024-08-13T08:04:06.136Z
6+
lastmod: 2024-08-13T11:34:21.076Z
77
weight: 880
88
---
99

10-
- Copilot integration
11-
- Custom field commands
10+
# AI features
11+
12+
Front Matter CMS allows you to make use of the GitHub Copilot's Large Language Model (LLM) to provide
13+
you title, description, and taxonomy suggestions.
14+
15+
## GitHub Copilot integration
16+
17+
In the July 2024 release of Visual Studio Code, extension developers are able to make use of the GitHub
18+
Copilot's Large Language Model (LLM). Front Matter CMS took advantage of this feature to provide you
19+
with the ability to provide title, description, and tags suggestions.
20+
21+
> **Important**: This feature is only available when you have the GitHub Copilot extension installed
22+
> and a valid license.
23+
24+
The AI features are available in the following places:
25+
26+
- Title suggestions when creating new content
27+
- Description suggestions based on the title and content
28+
- Taxonomy suggestions based on the title, content, and available tags
29+
30+
By default the `gpt-3.5-turbo` model is used to generate the suggestions. You can change the model
31+
by updating the `frontMatter.copilot.family` setting in your `frontmatter.json` file.
32+
33+
```json {{ "title": "Change GitHub Copilot's AI model" }}
34+
{
35+
"frontMatter.copilot.family": "gpt-4.0-turbo"
36+
}
37+
```
38+
39+
### Title suggestions
40+
41+
When creating new content when you have the GitHub Copilot extension installed, you will get title
42+
suggestions based on the provided title.
43+
44+
![Title suggestions provided by GitHub Copilot](/releases/v10.3.0/github-copilot-title-suggestions.webp)
45+
46+
### Description and taxonomy suggestions
47+
48+
For descriptions and tags, you will get a new field action button which allows you to generate suggestions
49+
based on the content.
50+
51+
![Trigger GitHub Copilot description suggestion](/releases/v10.3.0/github-copilot-description-suggestion.webp)
52+
53+
## Using your own AI
54+
55+
If you have your own AI APIs which you want to use. You make use of the `@frontmatter/extensibility`
56+
library to integrate it with Front Matter CMS.
57+
58+
You have the following integration points:
59+
60+
- [Field actions](/docs/content-creation/field-actions)
61+
- [Content scripts](/docs/custom-actions/content-scripts)
Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
---
2+
title: Field actions
3+
slug: content-creation/field-actions
4+
description: Learn how you can add your custom field actions to populate the field with a specific value.
5+
date: 2024-08-13T10:03:04.087Z
6+
lastmod: 2024-08-13T11:11:27.339Z
7+
weight: 200.52
8+
---
9+
10+
# Field actions
11+
12+
Field actions (`actions` property on the field) can be used to populate a field with a specific value.
13+
The difference between a field action
14+
and a placeholder is that the field action needs to be manually triggered by the user.
15+
16+
The field action can be used to populate the field with information coming from a script.
17+
For example to generate a unique ID.
18+
19+
The following field types support field actions:
20+
21+
- `string`: return a string value
22+
- `tags`: return an array of strings
23+
- `categories`: return an array of strings
24+
- `taxonomy`: return an array of strings
25+
- `image`: : return a string when single image is used, or an array of strings when multiple images
26+
are used
27+
28+
## Creating a new script
29+
30+
> **Important**: The field actions scripts make use of the `@frontmatter/extensibility` library.
31+
> More information to install it can be found in the [Extensibility library][01] section.
32+
33+
The `@frontmatter/extensibility` package provides you the following arguments for your field action script:
34+
35+
```javascript {{ "title": "Field action script" }}
36+
import { FieldAction } from '@frontmatter/extensibility';
37+
38+
(async () => {
39+
// Retrieve the front matter of the current content
40+
const { frontMatter } = FieldAction.getArguments();
41+
42+
// Write your logic here to create the field value
43+
const value = "Your value here";
44+
45+
// Update the field with the new value
46+
FieldAction.update(value);
47+
})();
48+
```
49+
50+
## Configure the script
51+
52+
The configuration of the field action is done on the content type field configuration.
53+
54+
```json {{ "title": "Field action configuration" }}
55+
{
56+
"frontMatter.taxonomy.contentTypes": [{
57+
"name": "sample",
58+
"fields": [{
59+
"title": "Title",
60+
"name": "title",
61+
"type": "string",
62+
"required": true,
63+
"actions": [{
64+
"title": "Update field value",
65+
"script": "./scripts/field.script.mjs",
66+
"command": "~/.nvm/versions/node/v20.11.1/bin/node"
67+
}]
68+
}
69+
}
70+
```
71+
72+
> **Info**: You are able to add multiple field actions to a single field.
73+
74+
Once the script has been configured, you can see the script action icon on the field.
75+
76+
- If you have a single field action defined and click the icon, the field action will be executed.
77+
- If you have multiple field actions defined, a dropdown will be shown with the available field actions.
78+
79+
![Custom field actions][02]
80+
81+
## Sample scripts
82+
83+
### Update title by Ollama AI
84+
85+
The following script will update the title field value with a title generated by the Ollama AI.
86+
87+
```javascript {{ "title": "Update title by Ollama AI" }}
88+
import { FieldAction } from '@frontmatter/extensibility';
89+
import ollama from 'ollama';
90+
91+
(async () => {
92+
const { frontMatter } = FieldAction.getArguments();
93+
94+
if (!frontMatter.title) {
95+
FieldAction.done();
96+
return;
97+
}
98+
99+
const ollamaResp = await ollama.chat({
100+
model: 'llama3',
101+
messages: [{
102+
role: 'user',
103+
content: `Create a SEO friendly title based on the given placeholder title. The title should be catchy and should contain the main keywords. The title should not exceed 60 characters in length. Desired format: just a string, e.g. "My first blog post" and you should not include anything else than the title.
104+
105+
The current placeholder title is: """${frontMatter.title}"""`
106+
}],
107+
stream: false
108+
});
109+
110+
let title = ollamaResp.message.content;
111+
112+
if (!title) {
113+
FieldAction.done();
114+
return;
115+
}
116+
117+
if (title.startsWith('"') && title.endsWith('"')) {
118+
title = title.slice(1, -1);
119+
}
120+
121+
FieldAction.update(title);
122+
})();
123+
```
124+
125+
#### Prerequisites
126+
127+
- Running [Ollama](https://ollama.com/) instance
128+
- `npm i ollama`
129+
130+
#### Configuration
131+
132+
```json {{ "title": "Update title" }}
133+
{
134+
"frontMatter.taxonomy.contentTypes": [{
135+
"name": "sample",
136+
"fields": [{
137+
"title": "Title",
138+
"name": "title",
139+
"type": "string",
140+
"required": true,
141+
"actions": [{
142+
"title": "Update title by Ollama AI",
143+
"script": "./scripts/fields/update-title.mjs",
144+
"command": "~/.nvm/versions/node/v20.11.1/bin/node"
145+
}]
146+
}
147+
}
148+
```
149+
150+
### Suggest titles by Ollama AI
151+
152+
Similar to the previous script, this script will suggest multiple titles generated by the Ollama AI
153+
and you can choose one of them to update the title field value.
154+
155+
> **Info**: The script makes use of the `askQuestions` method which allows you to ask the user to choose
156+
> from a list of options.
157+
158+
```javascript {{ "title": "Suggest titles by Ollama AI" }}
159+
import { FieldAction } from '@frontmatter/extensibility';
160+
import ollama from 'ollama';
161+
162+
(async () => {
163+
const { frontMatter, answers } = FieldAction.getArguments();
164+
165+
if (!answers) {
166+
if (!frontMatter.title) {
167+
FieldAction.done();
168+
return;
169+
}
170+
171+
const ollamaResp = await ollama.chat({
172+
model: 'llama3',
173+
messages: [{
174+
role: 'user',
175+
content: `Create a SEO friendly titles based on the given placeholder title. The titles should be catchy and should contain the main keywords. The titles should not exceed 60 characters in length.
176+
177+
Desired format: just a string wrapped in quotes, e.g. "My first blog post" and you should not include anything else than the title.
178+
179+
You should suggest at least 3 titles. Each suggestion is created on a new line.
180+
181+
The current placeholder title is: """${frontMatter.title}"""`
182+
}],
183+
stream: false
184+
});
185+
186+
let titles = ollamaResp.message.content;
187+
188+
if (!titles) {
189+
FieldAction.done();
190+
return;
191+
}
192+
193+
titles = titles.split('\n')
194+
.map(title => title.trim())
195+
.filter(title => title && title.startsWith('"') && title.endsWith('"'))
196+
.map(title => {
197+
if (title.startsWith('"') && title.endsWith('"')) {
198+
title = title.slice(1, -1);
199+
}
200+
201+
return title;
202+
});
203+
204+
FieldAction.askQuestions([{
205+
name: "articleTitle",
206+
message: "Choose the best title",
207+
default: frontMatter.title,
208+
options: [decodeURIComponent(frontMatter.title), ...titles]
209+
}]);
210+
return;
211+
}
212+
213+
if (!answers.articleTitle) {
214+
FieldAction.done();
215+
return;
216+
}
217+
218+
FieldAction.update(answers.articleTitle);
219+
})();
220+
```
221+
222+
When the user triggers the field action, the script will ask the user to choose the best title
223+
from the suggestions it received from the Ollama AI.
224+
225+
![Title suggestions by Ollama AI][03]
226+
227+
#### Prerequisites
228+
229+
- Running [Ollama](https://ollama.com/) instance
230+
- `npm i ollama`
231+
232+
#### Configuration
233+
234+
```json {{ "title": "Update title" }}
235+
{
236+
"frontMatter.taxonomy.contentTypes": [{
237+
"name": "sample",
238+
"fields": [{
239+
"title": "Title",
240+
"name": "title",
241+
"type": "string",
242+
"required": true,
243+
"actions": [{
244+
"title": "Suggest titles by Ollama AI",
245+
"script": "./scripts/fields/suggest-titles.mjs",
246+
"command": "~/.nvm/versions/node/v20.11.1/bin/node"
247+
}]
248+
}
249+
}
250+
```
251+
252+
<!-- Link References -->
253+
254+
[01]: /docs/custom-actions#extensibility-library
255+
[02]: /releases/v10.3.0/field-actions.webp
256+
[03]: /releases/v10.3.0/field-actions-suggestions.webp

0 commit comments

Comments
 (0)