ExtraStatic: powerful and easy publishing

Skip to content

Add revision history widget

Chris Dawson requested to merge add_revision_history into main

Revision Changes

This change adds "revision history" to your blogs automatically. If a config option is set (off by default), Svekyll processes the git log for each post and provides a dialog which a user can click to view changes for that post.

This uses the incredible https://diff2html.xyz/ tool.

latest-changes

Safety Notes

Adding git history into a post can be dangerous if you have commits/changes which you don't want to share publicly. If your repository has a commit that you don't want to make public, then please don't enable this feature.

And, this widget attempts to only include information about the post which should be public according to these rules:

  1. You can disable revision history inside individual posts by adding revisions_disabled: true to your config file YFM.
  2. If the post is not marked as published inside the YFM, then revision history will not be published either.
  3. If the post has a history where the published attribute inside the YFM changes, then only publish changes which are after (and including) the change in publishing status.
  4. If, however, a user publishes, and then unpublishes, and then publishes again, do not include revision history in the post. It is too hard in this case to understand which commits should be published.
  5. If a user first publishes the post to a branch, this is experimental work, and do not include that history. Once the work has moved to main (or master) then publish those commits, but nothing before this. That same rules apply when a user publishes and unpublishes the work here: if you move a post back and forth between multiple branches, do not include revision history because that is too hard to understand.

Usage

Add this to your configuration:


revisions:
  enabled: true

Then, add the <Revision/> component, probably in a src/Postroll.svelte file like this:

<script>
  import Revisions from '$svekyll/Revisions.svelte';
  export let post;
</script>

<Revisions {post}/>
Edited by Chris Dawson

Merge request reports

Loading