How to link a draft in a Hexo post, that is not clickable until the draft is published?

30 views Asked by At

I would like to link a draft from an existing post such that Hexo will only display its text content (not clickable) unless:

  • it is run with hexo --draft (ergo 'display drafts' is enabled), or
  • the draft is published (ergo becomes a regular post).

Example source:

Flow automates projects to follow {% post_link flow-models 'git branching models' %}.

Assuming there is a draft called 'flow-models', the generated HTML is:

<p>Flow automates projects to follow git branching models.</p>

After publishing the draft or with 'display drafts' enabled, the HTML is:

<p>Flow automates projects to follow <a href="/drafts/flow-models">git branching models</a>.</p>

What actually happens in the given example is that Hexo generates a non-existing link with a current date (say today is April 9, 2023), that results into an error 404 (Not Found).

<p>Flow automates projects to follow <a href="/2023/04/09/flow-models">git branching models</a>.</p>

Hope this makes sense. Thank y'all for your thoughts.

0

There are 0 answers