Skip to content

Commit

Permalink
Merge pull request #71 from ratsclub/hugo-slug
Browse files Browse the repository at this point in the history
add 'url' to hugo frontmatter
  • Loading branch information
sirodoht authored Jul 17, 2024
2 parents 1d0253b + 608bd47 commit accb262
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main/views/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ def prepend_zola_frontmatter(body, post_title, pub_date):
return frontmatter + body


def prepend_hugo_frontmatter(body, post_title, pub_date):
def prepend_hugo_frontmatter(body, post_title, pub_date, post_slug):
frontmatter = "+++\n"
frontmatter += f'title = "{post_title}"\n'
frontmatter += f"date = {pub_date}\n"
frontmatter += f'url = "blog/{post_slug}"\n'
frontmatter += "+++\n"
frontmatter += "\n"

Expand Down Expand Up @@ -158,7 +159,7 @@ def export_hugo(request):
title = p.slug + ".md"
pub_date = p.published_at or p.created_at.date()
body = prepend_hugo_frontmatter(
p.body, util.escape_quotes(p.title), pub_date
p.body, util.escape_quotes(p.title), pub_date, p.slug
)
export_posts.append((title, io.BytesIO(body.encode())))

Expand Down

0 comments on commit accb262

Please sign in to comment.