`permalink` depends on `slug`
pesterhazy opened this issue · 6 comments
By default, the permalink
task only works if the slug
ask was run previously. This caught me off-guard.
Possible solutions:
- call slug if metadata key not already present?
- throw an exception at runtime if slog is not present
- warn at runtime if slug is not present
- add documentation
There's the SPEC.md
file which notes this dependency but we should definitely become smarter about errors in this context. Slightly elm-inspired here's an idea for an error that could be shown when the slug is missing.
Because slug-fn and similar parts of perun are swappable we can't do something fully generic at the task level I believe but maybe we can use clojure.spec
or similar on default fn's to give this kind of feedback.
I like this type of feedback. Looks super beginner friendly
And we could probably use puget to colorize the output + shorten long fields (string over 80 chars or such), so we don't manually need to dissoc long fields (content).
And this is once again a place we would need to throw a exception to stop Boot pipeline, but showing the stacktrace wouldn't make much sense. But this should be fixed in the next Boot version: boot-clj/boot#486
This is what I used to omit long values :D
(defn omit-long-vals [m]
(reduce-kv (fn [m k v]
(if (and (string? v) (< 150 (count v)))
(assoc m k ::omitted)
m))
m
m))
Fixed as of 4638cd5.
:slug
, :permalink
, and :canonical-url
* are now based on a file's path in the fileset, and automatically set for you when metadata is accessed. In many cases, this means you don't need to run the slug
and permalink
tasks at all, but you still can, if you want to move the files to new locations, based on a slug or permalink. The canonical-url
task is deprecated, because there is no advantage to moving a file given a new canonical url, over a new permalink.
* note, you still must have the :base-url
global metadata set in order for :canonical-url
to be set for you.