Skip to content

Commit

Permalink
Use parent instead of previous (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
purajit authored Mar 10, 2023
1 parent b05884d commit 22daf10
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ The above section went over some of this, but to summarize:
* `data`: the actual data of the page, either a json or text blob based on the sitemap definition
* `title`: this is what the parent of a page will be given as part of its children list
* `tab_title`: additional parameter that defaults to `title` that you can use as the actual HTML title if you wish
* `previous_page`: a link to the parent page
* `parent_page`: a link to the parent page
* `static_url`: defaults to the empty string, but can be used to switch out the source of your statics
* All parameters in `global_template_parameters` (see below)

Expand Down Expand Up @@ -166,8 +166,6 @@ However, I prefer the sitemap being explicit and all in one place; this also all

## Future work
* Allow for templating of static files
* Rename `previous_page` to `parent_page` (breaking change)
* The template essentially defines the data type it accepts, so maybe find a way to make that work automatically

## Used by
<p align="center">
Expand Down
10 changes: 5 additions & 5 deletions generate_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ def generate_page_params(yass_config, level_path, level_data):
return params


def generate_level(yass_config, level_map, previous_level_path):
def generate_level(yass_config, level_map, parent_level_path):
print(level_map)
level_name = level_map["route"]
level_path = os.path.join(previous_level_path, level_name)
level_path = os.path.join(parent_level_path, level_name)
output_file = os.path.join(level_path, "index.html")
link = os.path.join("/", level_path)
template = level_map.get("template", "template_contents.html")

LOG.info(f"Generating: {previous_level_path} | {level_path} | {output_file} | {link} | {template}")
LOG.info(f"Generating: {parent_level_path} | {level_path} | {output_file} | {link} | {template}")

if "children" in level_map:
# generate children and get table of contents
Expand All @@ -75,7 +75,7 @@ def generate_level(yass_config, level_map, previous_level_path):
params = {
"title": level_map["title"],
"tab_title": level_map.get("tab_title", level_map["title"]),
"previous_page": os.path.join("/", previous_level_path),
"parent_page": os.path.join("/", parent_level_path),
"static_url": yass_config["static_url"],
**yass_config["global_template_parameters"],
**additional_params,
Expand All @@ -91,7 +91,7 @@ def generate_level(yass_config, level_map, previous_level_path):


def generate_site(yass_config):
return generate_level(yass_config, yass_config["sitemap"], previous_level_path="")
return generate_level(yass_config, yass_config["sitemap"], parent_level_path="")


def generate_statics(yass_config):
Expand Down

0 comments on commit 22daf10

Please sign in to comment.