From 8a4d5e6e36b7587004cecb947f313d993c87a702 Mon Sep 17 00:00:00 2001 From: "Kevin C. Moore" Date: Sun, 16 Feb 2025 01:47:55 +0000 Subject: [PATCH] More macros tests --- main.py | 5 +++-- mkdocs.yml | 20 ++++++++------------ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/main.py b/main.py index 8c2dade..f845b66 100644 --- a/main.py +++ b/main.py @@ -1,17 +1,18 @@ import os +from datetime import datetime def define_env(env): """ This hook is called when the config is loading. """ - # Get environment variables with fallbacks username = os.getenv('GITHUB_REPOSITORY_OWNER', 'Ghost') repo_name = os.getenv('GITHUB_REPOSITORY', 'mkdocs-plex-guide-template').split('/')[-1] + current_year = datetime.now().year - # Add them to the macros environment env.variables.update({ "username": username, "repo_name": repo_name, + "year": current_year, "request_url": "request.example.com", "domain": "example.com" }) diff --git a/mkdocs.yml b/mkdocs.yml index ca9a05e..f13e53d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,5 +1,5 @@ -site_name: !ENV [GITHUB_REPOSITORY_OWNER, 'Ghost'] + '.github.io' -site_url: 'https://' + !ENV [GITHUB_REPOSITORY_OWNER, 'Ghost'] + '.github.io' +site_name: "{{ username }}.github.io" +site_url: "https://{{ username }}.github.io" theme: name: material logo: assets/images/plex-logo.webp @@ -69,13 +69,9 @@ plugins: - mkdocs-video - git-revision-date-localized - git-committers: - repository: !ENV [GITHUB_REPOSITORY, 'Ghost/repo'] + repository: "{{ username }}/{{ repo_name }}" branch: main - - macros: - variables: - username: !ENV [GITHUB_REPOSITORY_OWNER, 'Ghost'] - request_url: 'request.example.com' - domain: 'example.com' + - macros markdown_extensions: - toc: @@ -97,7 +93,7 @@ markdown_extensions: emoji_index: !!python/name:material.extensions.emoji.twemoji emoji_generator: !!python/name:material.extensions.emoji.to_svg -copyright: 'Copyright © ' + !ENV [CURRENT_YEAR, '2025'] + ' ' + !ENV [GITHUB_REPOSITORY_OWNER, 'Ghost'] +copyright: "Copyright © {{ year }} {{ username }}" extra_css: - stylesheets/extra.css @@ -105,11 +101,11 @@ extra_css: extra: social: - icon: fontawesome/brands/github - link: 'https://github.com/' + !ENV [GITHUB_REPOSITORY_OWNER, 'Ghost'] - name: !ENV [GITHUB_REPOSITORY_OWNER, 'Ghost'] + ' @ Github' + link: "https://github.com/{{ username }}" + name: "{{ username }} @ Github" - icon: fontawesome/brands/discord link: https://discord.com name: Discord Channel - icon: fontawesome/solid/globe - link: 'https://' + !ENV [GITHUB_REPOSITORY_OWNER, 'Ghost'] + '.github.io' + link: "https://{{ username }}.github.io" name: Personal Website