Skip to content

Commit e892d92

Browse files
authored
Use 3 levels of scope of data files (#36)
Data can now be in a separate namespace (in this case, the file name without extension) so that data coming from files like bibtex are better scoped. The updated rules around data files would be: * `{page}.{ext}`: added to the namespace of only `{page}.md` * `index.{ext}`: added to the namespace of each page in a folder. * `{data}.{ext}`: added to each page in a folder but in its own namespace `{data}` Previously, the yaml/json files put things under one or two variables, like "education" or "publications". Now, that level can be removed and set by the data file name instead.
1 parent c7bdb1a commit e892d92

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

nene/_api.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,19 @@ def build(config_file, console=None, style=""):
9696
for path in sorted(data_files):
9797
console.print(f" {str(path)}")
9898
data = load_data(path)
99-
if data["id"] in site:
99+
if data["id"] in site and not data["id"].endswith("/index"):
100100
propagate_to_page = [site[data["id"]]]
101101
else:
102102
propagate_to_page = [
103103
page for page in site.values() if page["parent"] == data["parent"]
104104
]
105105
for page in propagate_to_page:
106106
console.print(f" ↳ {page['id']}")
107-
# Merge the two data dictionaries with 'page' taking precedence
108-
page.update({**data["content"], **page})
107+
if data["id"].endswith("/index") or page["id"] == data["id"]:
108+
# Merge the two data dictionaries with 'page' taking precedence
109+
page.update({**data["content"], **page})
110+
else:
111+
page[data["id"].split("/")[-1]] = data["content"]
109112
else:
110113
console.print(" None found.")
111114

0 commit comments

Comments
 (0)