Allow setting alternative key names for tags and categories

New keywords/properties:

    #+HUGO_FRONT_MATTER_KEY_ORG_TAGS
    :EXPORT_HUGO_FRONT_MATTER_KEY_ORG_TAGS:

    #+HUGO_FRONT_MATTER_KEY_ORG_CATEGORIES
    :EXPORT_HUGO_FRONT_MATTER_KEY_ORG_CATEGORIES:

Add test cases / examples for this new feature.
master
Kaushal Modi 8 years ago
parent 31d17ee250
commit e5e6e87e71
  1. 12
      ox-hugo.el
  2. 15
      test/site/content-org/all-posts.org
  3. 9
      test/site/content/posts/alternative-categories-key.md
  4. 8
      test/site/content/posts/alternative-tags-key.md

@ -663,6 +663,8 @@ newer."
(:hugo-auto-set-lastmod "HUGO_AUTO_SET_LASTMOD" nil org-hugo-auto-set-lastmod)
(:hugo-custom-front-matter "HUGO_CUSTOM_FRONT_MATTER" nil nil)
(:hugo-blackfriday "HUGO_BLACKFRIDAY" nil nil)
(:hugo-front-matter-key-org-tags "HUGO_FRONT_MATTER_KEY_ORG_TAGS" nil "tags")
(:hugo-front-matter-key-org-categories "HUGO_FRONT_MATTER_KEY_ORG_CATEGORIES" nil "categories")
;; Front matter variables
;; https://gohugo.io/content-management/front-matter/#front-matter-variables
@ -2227,6 +2229,8 @@ INFO is a plist used as a communication channel."
(all-t-and-c-str (org-entry-get (point) "ALLTAGS"))
(all-t-and-c (when (stringp all-t-and-c-str)
(org-split-string all-t-and-c-str ":")))
(tags-key (intern
(plist-get info :hugo-front-matter-key-org-tags)))
(tags (or
;; Look for tags set using #+HUGO_TAGS keyword, or
;; EXPORT_HUGO_TAGS property if available.
@ -2238,6 +2242,8 @@ INFO is a plist used as a communication channel."
(tags-list (org-hugo--transform-org-tags tags-list info)))
;; (message "[get fm DBG] tags: tags-list = %S" tags-list)
tags-list)))
(categories-key (intern
(plist-get info :hugo-front-matter-key-org-categories)))
(categories (or
;; Look for categories set using
;; #+HUGO_CATEGORIES keyword, or
@ -2297,8 +2303,8 @@ INFO is a plist used as a communication channel."
(markup . ,(org-export-data (plist-get info :hugo-markup) info))
(outputs . ,outputs)
(slug . ,(org-export-data (plist-get info :hugo-slug) info))
(tags . ,tags)
(categories . ,categories)
(,tags-key . ,tags)
(,categories-key . ,categories)
(type . ,(org-export-data (plist-get info :hugo-type) info))
(url . ,(org-export-data (plist-get info :hugo-url) info))
(weight . ,weight)
@ -2319,6 +2325,8 @@ INFO is a plist used as a communication channel."
;; (message "[custom fm data DBG] %S" custom-fm-data)
;; (message "[fm resources OUT DBG] %S" resources)
;; (message "[fm data DBG] %S" data)
;; (message "[fm tags key DBG] %s" tags-key)
;; (message "[fm categories key DBG] %s" categories-key)
;; (message "[fm tags DBG] %S" tags)
;; (message "[fm categories DBG] %S" categories)
(org-hugo--gen-front-matter data fm-format)))

@ -3726,6 +3726,21 @@ This post has 1 author.
:END:
This post has multiple authors. In Org, multiple authors are added
comma-separated.
** Alternative front-matter keys :alternative:keys:
*** Alternative "tags" key :tags:
:PROPERTIES:
:EXPORT_FILE_NAME: alternative-tags-key
:EXPORT_HUGO_FRONT_MATTER_KEY_ORG_TAGS: keywords
:END:
This post will have the =tags= key in front-matter renamed to
=keywords=.
*** Alternative "categories" key :categories:@test_cat_x:
:PROPERTIES:
:EXPORT_FILE_NAME: alternative-categories-key
:EXPORT_HUGO_FRONT_MATTER_KEY_ORG_CATEGORIES: cats
:END:
This post will have the =categories= key in front-matter renamed to
=cats=.
* Real Examples :real_examples:
:PROPERTIES:
:EXPORT_HUGO_SECTION: real-examples

@ -0,0 +1,9 @@
+++
title = "Alternative \"categories\" key"
tags = ["front-matter", "alternative", "keys", "categories"]
cats = ["test-cat-x"]
draft = false
+++
This post will have the `categories` key in front-matter renamed to
`cats`.

@ -0,0 +1,8 @@
+++
title = "Alternative \"tags\" key"
keywords = ["front-matter", "alternative", "keys", "tags"]
draft = false
+++
This post will have the `tags` key in front-matter renamed to
`keywords`.
Loading…
Cancel
Save