-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable replacing any key in the front-matter
New Org keyword/property: #+HUGO_FRONT_MATTER_KEY_REPLACE :EXPORT_HUGO_FRONT_MATTER_KEY_REPLACE: This commit obsoletes the 2 new keywords/properties pairs introduced in an earlier commit today: e5e6e87 Earlier approach was hard-coded to replace only tags and categories keys in the front-matter. This new approach used in this commit can replace *any* front-matter key with the string the user wants. The syntax is: #+HUGO_FRONT_MATTER_KEY_REPLACE: oldkey>newkey You can also do multiple key replacements: #+HUGO_FRONT_MATTER_KEY_REPLACE: oldkey1>newkey1 oldkey2>newkey2 Note that: 1. There are no spaces around the special character ">". 2. Spaces are used to only separate multiple replacements are shown in the second example above. 3. The replacements are literal.. there are no regular expressions involved.
- Loading branch information
1 parent
240dd55
commit b72a5fb
Showing
9 changed files
with
132 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
test/site/content/posts/replace-both-tags-and-categories-keys.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
+++ | ||
title = "Replace both \"tags\" and \"categories\" keys" | ||
keywords = ["front-matter", "keys", "replace", "tags", "categories"] | ||
cats = ["test-cat-x"] | ||
draft = false | ||
+++ | ||
|
||
This post will have the `tags` key in front-matter replaced with | ||
`keywords` and `categories` replaced with `cats`. |
9 changes: 9 additions & 0 deletions
9
test/site/content/posts/replace-keys-using-multiple-properties.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
+++ | ||
title = "Replace keys using multiple properties" | ||
keywords = ["front-matter", "keys", "replace", "tags", "categories"] | ||
cats = ["test-cat-x"] | ||
draft = false | ||
+++ | ||
|
||
This post will have the `tags` key in front-matter replaced with | ||
`keywords` and `categories` replaced with `cats`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
+++ | ||
title = "Replace only \"categories\" key" | ||
tags = ["front-matter", "keys", "replace", "categories"] | ||
cats = ["test-cat-x"] | ||
draft = false | ||
+++ | ||
|
||
This post will have the `categories` key in front-matter replaced with | ||
`cats`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
+++ | ||
title = "Replace only \"linkTitle\" key" | ||
linktitle = "Replace only \"linkTitle\" key" | ||
tags = ["front-matter", "keys", "replace", "linktitle"] | ||
draft = false | ||
+++ | ||
|
||
This post will have the `linkTitle` key in front-matter replaced with | ||
`linktitle`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
+++ | ||
title = "Replace only \"tags\" key" | ||
keywords = ["front-matter", "keys", "replace", "tags"] | ||
draft = false | ||
+++ | ||
|
||
This post will have the `tags` key in front-matter replaced with | ||
`keywords`. |