diff --git a/README.md b/README.md index 5eb76a9..454902f 100644 --- a/README.md +++ b/README.md @@ -26,5 +26,5 @@ All markdown files in the same folder and in subfolders automatically get all ta `meta_filename` Change the default name of the meta file. (default=`.meta.yml`) -`merge_tags` -Merge the tags of all relevant meta files and pages for a page (default=`false`) +`merge_entries` +Merge all specified entries of meta files and pages for a page that affects them according to the hirearchie (default=`[]`) diff --git a/mkdocs_meta_manager_plugin/plugin.py b/mkdocs_meta_manager_plugin/plugin.py index ea650a1..53e58cf 100644 --- a/mkdocs_meta_manager_plugin/plugin.py +++ b/mkdocs_meta_manager_plugin/plugin.py @@ -9,7 +9,7 @@ class MetaManagerPlugin(BasePlugin): config_scheme = ( ('meta_filename', config_options.Type(str, default='.meta.yml')), - ('merge_tags', config_options.Type(bool, default=False)), + ('merge_entries', config_options.Type(list, default=[])), ) meta_files = {} @@ -31,7 +31,6 @@ def on_pre_build(self, config): except yaml.YAMLError as exc: print(exc) logging.debug(self.meta_files) - def on_page_markdown(self, markdown, page, config, files): if not self.enabled: @@ -44,8 +43,9 @@ def on_page_markdown(self, markdown, page, config, files): for key, value in self.meta_files[part].items(): if not key in page.meta: page.meta[key] = value - elif key == 'tags' and self.config['merge_tags']: - page.meta[key] = page.meta[key].copy() + elif key in self.config['merge_entries']: + if not isinstance(page.meta[key], list): + page.meta[key] = [page.meta[key]] page.meta[key].extend(value) logging.debug("%s: %s", page.file.src_path, page.meta) diff --git a/setup.py b/setup.py index b58b2ef..2fa5c5e 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='mkdocs-meta-manager', - version='0.2.1', + version='1.0.0', description='MkDocs plugin for managing meta tags across folders and files.', long_description=long_description, long_description_content_type="text/markdown",