Unpublishable section of page or pre-publish API hook

Use case or problem

I’ve just started paying for publish and I’m considering what my strategy will be for publishing notes. One of the things in particular I’d like to be able to achieve is to have both public and private notes on the same document, just separated by some clear deliminator. This is somewhat related to other requests for more granular control over what’s published.

Proposed solution

There’s two ways that I think this could be accomplished.

  1. An option could be made to recognize a delimiter in which all content after that character sequence would be truncated and not included in the publish. That would satisfy my workflow, but it’s probably very specific to my workflow.

  2. A pre-publish hook could be added to the plugin API.

    import { TAbstractFile, Publish } from 'obsidian';
    Publish.prePublish((file: TAbstractFile, content: string): string | false => {
      // Do something with content, return false to skip publishing
      return content

This mechanism would likely be easier to implement and give the community a lot of flexibility and control around how & what they publish.

Current workaround (optional)

I haven’t figured out a good work around yet short of trying to pry open the publish plugin to poke around to see if I can do what I want.

An idea I had was to write a plugin that will spilt the editor view and automatically open a file of the same name if it exists a folder called private in your current vault. It technically does what I want, but I don’t like that I’d end up with backlinks to different files

Related feature requests (optional)

1 Like

I’ve decided that I’m going to make a custom plugin that monkey patches the API for now to do what I need.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.