cryogen-project / cryogen-core

Cryogen's core
Eclipse Public License 1.0
69 stars 62 forks source link

Add :update-article-fn to customize parsed page/.. #130

Closed holyjak closed 4 years ago

holyjak commented 4 years ago

Allow users to supply a function run on every parsed page/post to update it.

Example uses:

NOTE

I struggled to find a good name for "post or page". In the end I have fallen back on the HTML standard and adopted the name it uses for the "main content", i.e. "article". Any better ideas?

NOTE 2

Notice that while extend-params-fn runs very late in the process, this runs very early so it can modify the base data used to create the various site data such as posts and posts-by-tags, while extend-params-fn would need to modify all the places where e..g a particular post is used.

lacarmen commented 4 years ago

I have fallen back on the HTML standard and adopted the name it uses for the "main content", i.e. "article". Any better ideas?

Let's leave it at that, naming is hard 😆.

Will you update the docs site again? A couple of examples that illustrates the flexibility/power this adds would be great!

holyjak commented 4 years ago

That's the plan, after this is merged.

Thanks!

On Mon, 9 Dec 2019, 17:02 Carmen La, notifications@github.com wrote:

I have fallen back on the HTML standard and adopted the name it uses for the "main content", i.e. "article". Any better ideas?

Let's leave it at that, naming is hard 😆.

Will you update the docs site again? A couple of examples that illustrates the flexibility/power this adds would be great!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cryogen-project/cryogen-core/pull/130?email_source=notifications&email_token=AAEYSPQH4GDNWARLWYKVBCDQXZTYPA5CNFSM4JYG6DP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGJWD5Q#issuecomment-563306998, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEYSPVYKQ7GW3CFJJ2UQQTQXZTYPANCNFSM4JYG6DPQ .

holyjak commented 4 years ago

DON'T MERGE pls

I realized it would be better to pass also config to the function so I will add that (so that we have access e.g. to blog-prefix in in)

holyjak commented 4 years ago

Ready to merge.

I have updated it to send also the config to the function and to make it possible to return nil from the fn to exclude the article from the blog.

holyjak commented 4 years ago

See cryogen-project/cryogen-docs#27 for the corresponding docs change.

lacarmen commented 4 years ago

Looks great -- good call on passing in the config and returning nil to exclude articles :) Will push out new versions now!

lacarmen commented 4 years ago

And thank you again for all the great features you've been adding!

holyjak commented 4 years ago

My bad, thank you!

On Tue, Dec 10, 2019 at 3:36 PM Carmen La notifications@github.com wrote:

@lacarmen commented on this pull request.

In src/cryogen_core/compiler.clj https://github.com/cryogen-project/cryogen-core/pull/130#discussion_r356071931 :

([] (compile-assets {}))

  • ([overrides]
  • ([{:keys [extend-params-fn update-article-fn]
  • :or {extend-params-fn (fn [params _] params)
  • update-article-fn identity}

Oh, this can't be identity because it's called with 2 args, but I can fix it :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cryogen-project/cryogen-core/pull/130?email_source=notifications&email_token=AAEYSPVPMS55QA32UAJYKSLQX6SPNA5CNFSM4JYG6DP2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCOUZINA#pullrequestreview-329880628, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEYSPQL7O3FAHT72MIM5STQX6SPNANCNFSM4JYG6DPQ .