Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
vadimkantorov committed Jul 18, 2024
1 parent efdee96 commit b4a6742
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
run: curl -O https://raw.githubusercontent.com/vadimkantorov/nanojekyll/release/nanojekyll.py

- name: Build with zrxiv
run: python zrxivrender.py #demo.py --baseurl "${{ steps.pages.outputs.base_path }}" --siteurl "https://${{ github.repository_owner }}.github.io"
run: python zrxivrender.py --github-owner-name "${{ github.repository_owner }}" --github-url "https://${{ github.repository_owner }}.github.io/${{ github.repository }}" --siteurl "https://${{ github.repository_owner }}.github.io" --baseurl "${{ steps.pages.outputs.base_path }}"

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
Expand Down
10 changes: 9 additions & 1 deletion zrxivrender.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
parser.add_argument('--layouts-dir', default = '_layouts/')
parser.add_argument('--data-dir', default = 'data/')
parser.add_argument('--docs-dir', default = 'data/old_documents')
parser.add_argument('--github-url', default = '')
parser.add_argument('--github-owner-name', default = '')
parser.add_argument('--baseurl', default = '')
parser.add_argument('--siteurl', default = '')
args = parser.parse_args()

config = nanojekyll.NanoJekyllContext.yaml_loads(open(args.config_yml).read(), convert_int = True, convert_bool = True)
Expand All @@ -27,13 +31,17 @@
#cls = __import__(os.path.splitext(args.codegen_py)[0]).NanoJekyllContext
print(args.codegen_py)

ctx = dict(site = dict(config, pages = [], data = dict(documents = list(docs.items()))))
ctx = dict(site = dict(config, siteurl = args.siteurl, baseurl = args.baseurl, github = dict(url = args.github_url, owner_name = args.github_owner_name), pages = [], data = dict(documents = list(docs.items()))))

os.makedirs(args.output_dir, exist_ok = True)
print(args.output_dir)
for d in config['defaults']:
if d['scope']['path'] != 'data/tags/*.md':
continue

if '*' in d['scope']['path']:
for path in glob.glob(d['scope']['path']):
#breakpoint()
output_path = os.path.join(args.output_dir, d['values']['permalink'].replace(':basename', os.path.splitext(os.path.basename(path))[0]).lstrip('/') + 'index.html' * (d['values']['permalink'][-1] == '/'))
os.makedirs(os.path.dirname(output_path), exist_ok = True)
print(cls(dict(ctx, page = dict(d['values'], path = path, name = os.path.basename(path)))).render(d['values']['layout']), file = open(output_path, 'w'))
Expand Down

0 comments on commit b4a6742

Please sign in to comment.