Skip to content

Commit

Permalink
Don't allow weight to be "auto" in front-matter for per-file exports
Browse files Browse the repository at this point in the history
Fixes #83
  • Loading branch information
kaushalmodi committed Sep 28, 2017
1 parent 0318cb7 commit 32d0d97
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 5 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Time-stamp: <2017-09-26 14:20:42 kmodi>
# Time-stamp: <2017-09-28 10:05:44 kmodi>

# Makefile to export org documents to md for Hugo from the command line
# Run just "make" to see usage examples.
Expand Down Expand Up @@ -44,7 +44,8 @@ subtree_test_files = all-posts.org \

file_test_files = single-posts/post-toml.org \
single-posts/post-yaml.org \
single-posts/post-draft.org
single-posts/post-draft.org \
single-posts/hugo-auto-weight-ineffective-for-per-file-exports.org

# Cannot run tests on the following files, because:
# - auto-set-lastmod.org - the lastmod field will always get updated.
Expand Down
3 changes: 2 additions & 1 deletion doc/content/doc/org-meta-data-to-hugo-front-matter.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ Hugo front-matter (TOML) | Org

- The auto weight calculation for posts and menu items works **only**
for subtree exports. For the complete-file export flow, one needs to
specify the weights manually if needed.
specify the weights manually. The value of _weight_ set to `"auto"`
will be equivalent to _nil_ for the complete-file export flow.
1 change: 1 addition & 0 deletions doc/github-files.org
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#+MACRO: travis [[https://travis-ci.org/kaushalmodi/ox-hugo][https://travis-ci.org/kaushalmodi/ox-hugo.svg?branch=master]]
#+MACRO: melpa [[https://melpa.org/#/ox-hugo][file:https://melpa.org/packages/ox-hugo-badge.svg]]
#+MACRO: GPLv3 [[https://www.gnu.org/licenses/gpl-3.0][https://img.shields.io/badge/License-GPL%20v3-blue.svg]]
#+MACRO: gitter [[https://gitter.im/KaushalModi/Lobby][https://badges.gitter.im/KaushalModi/Lobby.svg]]

* Readme :readme:
:PROPERTIES:
Expand Down
3 changes: 2 additions & 1 deletion doc/ox-hugo-manual.org
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@ set.
***** Notes
- The auto weight calculation for posts and menu items works *only*
for subtree exports. For the complete-file export flow, one needs to
specify the weights manually if needed.
specify the weights manually. The value of /weight/ set to ="auto"=
will be equivalent to /nil/ for the complete-file export flow.
*** Formatting
:PROPERTIES:
:EXPORT_FILE_NAME: formatting
Expand Down
4 changes: 3 additions & 1 deletion ox-hugo.el
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,9 @@ INFO is a plist used as a communication channel."
org-hugo--subtree-coord)))
(if auto-calc
(org-hugo--calc-weight)
wt)))
(unless (and (stringp wt) ;Don't allow weight to be "auto" if auto-calc is nil.
(string= wt "auto"))
wt))))
(menu-alist (org-hugo--parse-menu-prop-to-alist (plist-get info :hugo-menu)))
(menu-alist-override (org-hugo--parse-menu-prop-to-alist (plist-get info :hugo-menu-override)))
;; If menu-alist-override is non-nil, update menu-alist with values from that.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#+TITLE: Hugo auto weight ineffective for per-file exports
#+HUGO_BASE_DIR: ../../
#+HUGO_WEIGHT: auto
#+HUGO_TAGS: weight

Even though we have =#+HUGO_WEIGHT: auto= in this file, the weight
will be treated as nil as this file is exported using the /per-file/
or /complete-file/ export flow.

The auto-weight calculation works *only* for /per-subtree/ flow.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
+++
title = "Hugo auto weight ineffective for per-file exports"
tags = ["weight"]
draft = false
+++

Even though we have `#+HUGO_WEIGHT: auto` in this file, the weight
will be treated as nil as this file is exported using the _per-file_
or _complete-file_ export flow.

The auto-weight calculation works **only** for _per-subtree_ flow.

0 comments on commit 32d0d97

Please sign in to comment.