@@ -38,22 +38,25 @@ contentFiles.forEach((oldFullPath) => {
38
38
// skip pages with frontmatter flag
39
39
if ( data . allowTitleToDifferFromFilename ) return
40
40
41
- // slugify the title of each article
42
- // where title = Foo bar
43
- // and slug = foo-bar
41
+ // Slugify the title of each article, where:
42
+ // * title = Foo bar
43
+ // * slug = foo-bar
44
+ // Also allow for the slugified shortTitle to match the filename.
44
45
slugger . reset ( )
45
- const slug = slugger . slug ( decode ( data . title ) )
46
+ const slugTitle = slugger . slug ( decode ( data . title ) )
47
+ const slugShortTitle = slugger . slug ( decode ( data . shortTitle ) )
48
+ const allowedSlugs = [ slugTitle , slugShortTitle ]
46
49
47
50
// get the basename of each file
48
51
// where file = content/foo-bar.md
49
52
// and basename = foo-bar
50
53
const basename = path . basename ( oldFullPath , '.md' )
51
54
52
- // if slug and basename match, return early
53
- if ( basename === slug ) return
55
+ // If the basename is one of the allowed slugs, we're all set here.
56
+ if ( allowedSlugs . includes ( basename ) ) return
54
57
55
58
// otherwise rename the file using the slug
56
- const newFullPath = oldFullPath . replace ( basename , slug )
59
+ const newFullPath = oldFullPath . replace ( basename , slugShortTitle || slugTitle )
57
60
58
61
const oldContentPath = path . relative ( process . cwd ( ) , oldFullPath )
59
62
const newContentPath = path . relative ( process . cwd ( ) , newFullPath )
0 commit comments