Quick Parts / Autotext ?
-
For some topics I want to have specific headers like time and date e.g. ....
But instead of repetitive writing
#anchor(29.02.2024)
I would like to have something like quick parts we all know from documents where date and time are like an Autotext ...
#anchor(dd.mm.yyyy | hh:mm)
What's a smart way to achieve such a funcitonality? Probably it is pretty easy to write a simply plugin which does that but I don't know how ... I appreciate any advice! Thx.
-
@schajuli You could create a custom JS function for this that listens on
action:composer.preview
,action:posts.loaded
, andaction:posts.edited
and then rewrites the text into the format you'd like. The only issue I see with such a method is that you couldn't usenow()
for example as each time you load that specific post, the date and time would be reflective of current, and not the actual "stamped" time. It would be relatively simple to write in terms of a function - but you'd need to target the specific text in the post, and without anid
to reference, searching the DOM for that specific element can be expensive in terms of performance.I may be over thinking the approach, so I'll defer to others for potentially better ideas, such as extending the Markdown plugin.
-
TIL pressing F5 in notepad will insert the Time & Date stamp. Which is nice, so probably I'll just write a script for myself to automate the timestamp insertion as it should not be dynamically on site loading/refreshing - also performance wise it might lead to issues. Don't know if there is a way to add this functionality to the composer though - similiar like for the emojis. If there is a comprehensive guide to do so or at least to get started with it I'll add it to my todo-if-too-much-time list.