Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ Allowed values:
- `true` - Prepend the date, in the format `<year>-<month>-<day>`. Nothing will be prepended if there is no date (for example, an undated draft post).
- `false` - Don't prepend the date.

### Use post ID instead of slug?

```
--use-id=true
```

Whether to use the post ID instead of the post slug when naming post folders or files.

Note that if the slug is included in the frontmatter, some site generators (such as Hugo) will still use it when generating *their* paths, so you may wish to exclude `slug` from the frontmatter, or rename it to something else using the `--frontmatter-fields` option, for example::

```
--frontmatter-fields=title,date,id,slug:wpSlug
```

### Organize posts into date folders?

```
Expand Down
18 changes: 18 additions & 0 deletions src/questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ export function load() {
isPathQuestion: true,
prompt: inquirer.select
},
{
name: 'use-id',
type: 'boolean',
description: 'Use post ID instead of slug when naming files or folders',
default: false,
choices: [
{
name: 'Yes',
value: true
},
{
name: 'No',
value: false
}
],
isPathQuestion: true,
prompt: inquirer.select
},
{
name: 'date-folders',
type: 'choice',
Expand Down
4 changes: 4 additions & 0 deletions src/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export function buildPostPath(post, overrideConfig) {

// get slug with fallback
let slug = getSlugWithFallback(post);
// use ID instead of slug if specified
if (pathConfig.useId) {
slug = post.id.toString();
}

// prepend date to slug as appropriate
if (pathConfig.prefixDate && post.date) {
Expand Down