Skip to content

Commit 7be1d1f

Browse files
committed
Added slug documentation
1 parent 00b5abf commit 7be1d1f

File tree

9 files changed

+155
-36
lines changed

9 files changed

+155
-36
lines changed

.github/workflows/settings-verification.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- uses: actions/checkout@v2
16-
- uses: actions/setup-node@v3
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-node@v4
1717
with:
18-
node-version: 16
19-
cache: 'npm'
18+
node-version: 18
19+
cache: "npm"
2020

2121
- name: Install the dependencies
2222
run: npm ci
23-
23+
2424
- name: Verify missing settings
2525
run: node scripts/verify-settings.js ${{ github.ref_name }}
26-

components/Page/DocsLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const DocsLayout: React.FunctionComponent<React.PropsWithChildren<IDocsLa
2020
return (
2121
<div className={`lg:ml-72 xl:ml-80`}>
2222

23-
<aside className={`fixed inset-y-0 left-0 z-40 contents w-72 overflow-y-auto px-6 pt-4 pb-8 lg:block xl:w-80 lg:pr-8 lg:border-r lg:border-vulcan-300`}>
23+
<aside className={`fixed bg-vulcan-600 inset-y-0 left-0 z-40 contents w-72 overflow-y-auto px-6 pt-4 pb-8 lg:block xl:w-80 lg:pr-8 lg:border-r lg:border-vulcan-300`}>
2424
<div className='ml-auto'>
2525
<Header navItems={navItems} />
2626
</div>

content/changelog/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@
55
### ✨ New features
66

77
- [#731](https://github.com/estruyf/vscode-front-matter/issues/731): Added the ability to map/unmap taxonomy to multiple pages at once
8+
- [#746](https://github.com/estruyf/vscode-front-matter/issues/746): Placeholder support added to to the `slug` field
89
- [#749](https://github.com/estruyf/vscode-front-matter/issues/749): Ability to set your own filters on the content dashboard with the `frontMatter.content.filters` setting
910

1011
### 🎨 Enhancements
1112

13+
- [#673](https://github.com/estruyf/vscode-front-matter/pull/673): Added git settings to the welcome view and settings view
1214
- [#727](https://github.com/estruyf/vscode-front-matter/pull/727): Updated Japanese translations thanks to [mayumihara](https://github.com/mayumih387)
1315
- [#737](https://github.com/estruyf/vscode-front-matter/issues/737): Optimize the grid layout of the content and media dashboards
16+
- [#739](https://github.com/estruyf/vscode-front-matter/pull/739): New Git settings to disable and require a commit message
1417
- [#741](https://github.com/estruyf/vscode-front-matter/issues/741): Added message on the content dashboard when content is processed
1518
- [#747](https://github.com/estruyf/vscode-front-matter/issues/747): The `@frontmatter/extensibility` dependency now supports scripts for placeholders
19+
- [#752](https://github.com/estruyf/vscode-front-matter/issues/752): Placeholder support in default `list` field values
1620

1721
### ⚡️ Optimizations
1822

content/docs/commands.md

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Commands
33
slug: commands
44
description: null
55
date: 2021-08-30T16:13:00.546Z
6-
lastmod: 2023-09-11T07:58:42.087Z
6+
lastmod: 2024-02-13T09:43:12.442Z
77
weight: 900
88
---
99

@@ -133,26 +133,7 @@ ID: `frontMatter.createContent`
133133
This command generates a clean slug for your content. It removes known stop words, punctuations, and
134134
special characters.
135135

136-
Example:
137-
138-
```yaml
139-
---
140-
title: Just a sample page with a title
141-
slug: sample-page-title
142-
---
143-
```
144-
145-
You can also specify a prefix and suffix, which can be added to the slug if you want. Use the
146-
following settings to do this: `frontMatter.taxonomy.slugPrefix` and
147-
`frontMatter.taxonomy.slugSuffix`.
148-
149-
By default, both prefix and suffix settings are not provided, which mean it would not add anything
150-
extra to the slug.
151-
152-
Another setting is to allow you to sync the filename with the generated slug. The setting you need
153-
to turn on enable for this is `frontMatter.taxonomy.alignFilename`.
154-
155-
> **Info**: At the moment, the extension only supports English stopwords.
136+
> **Info**: You can read more about the slug in the [slug documentation](/docs/content-creation/slug).
156137
157138
ID: `frontMatter.generateSlug`
158139

content/docs/content-creation/content-type.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Content types
33
slug: content-creation/content-types
44
description: null
55
date: 2022-03-14T08:43:17.483Z
6-
lastmod: 2023-12-08T09:13:41.283Z
6+
lastmod: 2024-02-13T09:20:18.028Z
77
weight: 200.1
88
---
99

@@ -130,6 +130,7 @@ For the content type you can configure the following properties:
130130
| `template` | `string` | Specify a path to a template file that will be used when creating new content with the content type | `null` |
131131
| `allowAsSubContent` | `boolean` | Allow the content type to be used as sub-content | `false` |
132132
| `isSubContent` | `boolean` | Defines the content type as sub-content | `false` |
133+
| `slugTemplate` | `boolean` | Defines the template for the `slug` | `{{title}}` |
133134

134135
## Define your own type
135136

content/docs/content-creation/fields.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Fields
33
slug: content-creation/fields
44
description: null
55
date: 2022-03-14T08:42:21.626Z
6-
lastmod: 2023-12-08T08:57:08.344Z
6+
lastmod: 2024-02-13T09:46:22.485Z
77
weight: 200.2
88
---
99

@@ -822,7 +822,7 @@ slug: version-8-0-0-release-notes
822822
```
823823

824824
> **Info**: The slug is generated based on the title of the page. More information about it can be
825-
> found in the [generate slug][15] command section.
825+
> found in the [slug documentation][15] section.
826826
827827
## contentRelationship
828828

@@ -958,7 +958,7 @@ want to group fields together.
958958
[12]: /assets/block-field-type.png
959959
[13]: /releases/v7.3.0/datafile-field.png
960960
[14]: /releases/v8.0.0/slug-field.png
961-
[15]: /docs/commands#generate-slug-based-on-content-title
961+
[15]: /docs/content-creation/slug
962962
[16]: /releases/v8.1.0/section-divider.png
963963
[17]: /releases/v8.1.0/section-heading.png
964964
[18]: /docs/experimental#enable-experimental-features

content/docs/content-creation/placeholders.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Placeholders
33
slug: content-creation/placeholders
44
description: null
55
date: 2022-03-14T08:42:21.626Z
6-
lastmod: 2024-01-31T16:32:05.190Z
6+
lastmod: 2024-02-13T09:22:26.586Z
77
weight: 200.4
88
---
99

@@ -31,7 +31,7 @@ automatically fill in values when creating a new content.
3131

3232
| Placeholder | Description | Works for |
3333
| ----------------------- | ---------------------------------------------------------- | ----------------------------------------------------- |
34-
| `{{fm.<field name>}}` | The value of the field in the front matter | `previewPath` on the page folder or the content-type. |
34+
| `{{fm.<field name>}}` | The value of the field in the front matter | `slugTemplate` and `previewPath` properties. |
3535
| `{{pathToken.<index>}}` | The value of the path token at the index | `previewPath` on the page folder or the content-type. |
3636
| `{{pathToken.relPath}}` | The relative value path staring from the page folder' path | `previewPath` on the page folder or the content-type. |
3737

@@ -149,7 +149,7 @@ Here is an example of a dynamic `uniqueId` placeholder:
149149
#### Placeholder script
150150

151151
To get started, you first need to install the
152-
[@frontmatter/extensibility](https://www.npmjs.com/package/@frontmatter/extensibility)
152+
[@frontmatter/extensibility](https://www.npmjs.com/package/@frontmatter/extensibility)
153153
dependency.
154154

155155
```bash

content/docs/content-creation/slug.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
title: Slug
3+
slug: content-creation/slug
4+
description: null
5+
date: 2024-02-13T09:28:37.205Z
6+
lastmod: 2024-02-13T09:48:46.199Z
7+
weight: 200.5
8+
---
9+
10+
# Slug
11+
12+
The slug is the part of the URL that identifies a page in a human-readable form.
13+
It is usually derived from the title of the page, but Front Matter CMS allows
14+
you to define a custom slug.
15+
16+
## Default slug
17+
18+
The default slug is derived from the title of the page. It is automatically
19+
generated when you create a new page. The default slug is a URL-friendly version
20+
of the title, with all letters in lowercase, spaces replaced with hyphens,
21+
removes stop words, and special characters.
22+
23+
```yaml {{ "title": "Example of the default slug" }}
24+
---
25+
title: Just a sample page with a title
26+
slug: sample-page-title
27+
---
28+
```
29+
30+
> **Info**: The extension only supports English stopwords.
31+
32+
## Custom slug
33+
34+
You can define a custom slug for your pages and it can be defined on global
35+
level or per content type.
36+
37+
### Global level
38+
39+
You can define a custom slug template for all pages in the `frontMatter.taxonomy.slugTemplate`
40+
setting. The template can contain [placeholders][01] that will be replaced with the
41+
actual values when creating a new page.
42+
43+
```json {{ "title": "Example of the global slug template" }}
44+
{
45+
"frontMatter.taxonomy.slugTemplate": "{{year}}/{{month}}/{{title}}"
46+
}
47+
```
48+
49+
> **Info**: The `{{title}}` placeholder in the slug template will be replaced with
50+
> what you typically get from the default slug.
51+
52+
### Per content type
53+
54+
You can define a custom slug template for each content type in the
55+
`frontMatter.taxonomy.contentTypes` setting. Similar to the global slug template,
56+
the template can contain placeholders that will be replaced with the actual
57+
values when creating a new page.
58+
59+
```json {{ "title": "Example of the content type slug template" }}
60+
{
61+
"frontMatter.taxonomy.contentTypes": [
62+
{
63+
"name": "post",
64+
"slugTemplate": "{{year}}/{{month}}/{{title}}",
65+
...
66+
}
67+
]
68+
}
69+
```
70+
71+
## Additional settings
72+
73+
### Prefix and suffix
74+
75+
You can also specify a prefix and suffix, which can be added to the slug if you
76+
want. Use the following settings to do this: `frontMatter.taxonomy.slugPrefix`
77+
and `frontMatter.taxonomy.slugSuffix`.
78+
79+
```json {{ "title": "Example of the slug prefix and suffix" }}
80+
{
81+
"frontMatter.taxonomy.slugPrefix": "/",
82+
"frontMatter.taxonomy.slugSuffix": "/"
83+
}
84+
```
85+
86+
```yaml {{ "title": "Example slug in combination with the prefix and suffix" }}
87+
---
88+
title: Just a sample page with a title
89+
slug: /sample-page-title/
90+
---
91+
```
92+
93+
By default, both prefix and suffix settings are not provided, which mean it would
94+
not add anything extra to the slug.
95+
96+
### Align filename with slug
97+
98+
Another setting is to allow you to sync the filename with the generated slug. The
99+
setting you need to turn on enable for this is `frontMatter.taxonomy.alignFilename`.
100+
101+
```json {{ "title": "Example of the align filename with slug" }}
102+
{
103+
"frontMatter.taxonomy.alignFilename": true
104+
}
105+
```
106+
107+
When you update the slug of the page, the filename will be automatically
108+
updated to match the slug.
109+
110+
<!-- Link References -->
111+
112+
[01]: /docs/content-creation/placeholders

content/docs/settings/available-settings.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Settings overview
33
slug: settings/overview
44
description: null
55
date: 2023-02-13T16:44:09.618Z
6-
lastmod: 2023-12-08T09:03:00.096Z
6+
lastmod: 2024-02-13T09:17:07.601Z
77
weight: 1100.2
88
---
99

@@ -424,6 +424,20 @@ Specify the commit message you want to use for the sync.
424424
- Type: `string`
425425
- Default: `Synced by Front Matter`
426426

427+
### frontMatter.git.disableOnBranches
428+
429+
Specify the branches on which you want to disable the Git actions.
430+
431+
- Type: `array`
432+
- Default: `[]`
433+
434+
### frontMatter.git.requiresCommitMessage
435+
436+
Specify the branches on which you want to require a commit message.
437+
438+
- Type: `array`
439+
- Default: `[]`
440+
427441
### frontMatter.git.submodule.push
428442

429443
Specify if you want to push the submodule changes to the remote repository.
@@ -760,6 +774,14 @@ Specify a suffix for the slug.
760774
- Type: `string`
761775
- Default: `""`
762776

777+
### frontMatter.taxonomy.slugTemplate
778+
779+
Specify the template for the slug. If you use `{{title}}`, it will create a clean slug based on the
780+
title.
781+
782+
- Type: `string`
783+
- Default: `{{title}}`
784+
763785
### frontMatter.taxonomy.tags
764786

765787
Specifies the tags which can be used in the Front Matter.

0 commit comments

Comments
 (0)