diff --git a/nikola/plugin_categories.py b/nikola/plugin_categories.py index a745a68773..6705e5ef35 100644 --- a/nikola/plugin_categories.py +++ b/nikola/plugin_categories.py @@ -493,6 +493,11 @@ class Taxonomy(BasePlugin): in the metadata. If set to None, the classification won't be stored in the metadata. + metadata_friendly_name = None: + The name to be used when storing the friendly names of the classification + in the metadata. If set to None, the friendly names won't be stored + in the metadata. + overview_page_variable_name = "taxonomy": When rendering the overview page, its template will have a list of classifications available in a variable by this name. @@ -576,6 +581,7 @@ class Taxonomy(BasePlugin): # Adjust the following values in your plugin! classification_name = "taxonomy" metadata_name = "taxonomy" + metadata_friendly_name = None overview_page_variable_name = "taxonomy" overview_page_hierarchy_variable_name = "taxonomy_hierarchy" more_than_one_classifications_per_post = False diff --git a/nikola/plugins/misc/taxonomies_classifier.py b/nikola/plugins/misc/taxonomies_classifier.py index d33cb66e2b..a69857b550 100644 --- a/nikola/plugins/misc/taxonomies_classifier.py +++ b/nikola/plugins/misc/taxonomies_classifier.py @@ -73,6 +73,12 @@ def _do_classification(self, site): post.meta[lang][taxonomy.metadata_name] = classifications[lang] else: post.meta[lang][taxonomy.metadata_name] = classifications[lang][0] if len(classifications[lang]) > 0 else None + if taxonomy.metadata_friendly_name is not None: + friendly_names = [taxonomy.get_classification_friendly_name(classification, lang) for classification in classifications[lang]] + if taxonomy.more_than_one_classifications_per_post: + post.meta[lang][taxonomy.metadata_friendly_name] = friendly_names + else: + post.meta[lang][taxonomy.metadata_friendly_name] = friendly_names[0] if len(friendly_names) > 0 else None # Add post to sets for classification in classifications[lang]: while True: