Skip to content

Commit

Permalink
Added Google Analytics and Subsection Sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Yuen authored and Peter Yuen committed Apr 10, 2022
1 parent 0f38144 commit 3849749
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ is_netlify = true
language_code = "en-US"
theme_color = "#fff"

ganalytics = "___GANALYTICS___"
timeformat = "%B %e, %Y"
timezone = "___TIMEZONE___"

Expand Down
8 changes: 5 additions & 3 deletions convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"LANDING_DESCRIPTION": "I have nothing but intelligence.",
"LANDING_BUTTON": "Steal some of my intelligence",
"SORT_BY": "title",
"GANALYTICS": "",
}

ZOLA_DIR = Path(__file__).resolve().parent
Expand Down Expand Up @@ -46,7 +47,7 @@ def step1():
raise NotFoundErr(f"FATAL ERROR: build.environment.{item} not set!")
else:
print(
f"WARNING: build.environment.{item} not set! Defaulting to {def_val}"
f"WARNING: build.environment.{item} not set! Defaulting to '{def_val}'."
)
environ[item] = def_val
else:
Expand Down Expand Up @@ -75,9 +76,9 @@ def step3():
"""

print_step("GENERATING _index.md")
sections = list(DOCS_DIR.glob("**/**"))
sections = list(sorted(DOCS_DIR.glob("**/**"), key=lambda x: str(x).lower()))
content = None
for section in sections:
for idx, section in enumerate(sections):
# Set section title as relative path to section
title = re.sub(r"^.*?content/docs/*", "", str(section))

Expand All @@ -97,6 +98,7 @@ def step3():
f"title: {title}",
"template: docs/section.html",
f"sort_by: {sort_by}",
f"weight: {idx}",
"---",
]
open(section / "_index.md", "w").write("\n".join(content))
Expand Down
4 changes: 3 additions & 1 deletion netlify.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ SITE_URL = ""
# Site Timezone
TIMEZONE = "Asia/Hong_Kong"
ZOLA_VERSION = "0.15.2"
# How to sort notes on the right sidebar ("date" or "title"), defaults to "title" if missing or invalid
# How to sort notes inside each section on the right sidebar ("date" or "title"), defaults to "title" if missing or invalid (subsections are sorted by title, the sort order cannot be changed)
SORT_BY = "title"
# Google Analytics Measurement ID
GANALYTICS = ""

0 comments on commit 3849749

Please sign in to comment.