Skip to content

Instantly share code, notes, and snippets.

View obsidian.templater.help.anthony-baker.meeting-template.js
<%*
// v0.1
/* START OF USER DEFINED SETTINGS */
// template to use
const templateFolder = "templates";
const templateName = "template_anthony.md";
// creating the new file
const newFileFolder = "test/meetings";
const openNewFile = false;
@GitMurf
GitMurf / obsidian.templater.query.section.keyword-page-name.js
Created May 30, 2022
When using headings with a [[page name]] in it, create a "search embed query" with all those headings expanded
View obsidian.templater.query.section.keyword-page-name.js
<%*
const noteName = tp.file.title;
let queryKeyword = await tp.system.prompt("Keyword for Section search query (do NOT add [ ] brackets around it)", noteName);
if(queryKeyword) {
// Un-comment the next line if you want the keyword to require [] brackets around it for backlinks matching purposes
queryKeyword = `\\[\\[${queryKeyword}[\\|\\]]`; // the | pipe check accounts for alias links
tR = `
# Keyword Section Query
\`\`\`query
View obsidian.templater.other.get-all-links-and-backlinks.js
View obsidian.templater.search.this-page.backlinks-namespaces.js
View obsidian.templater.search.section.keyword-journal-dates.js
<%*
let startDate = await tp.system.prompt('Start Date');
let endDate = await tp.system.prompt('End Date');
const nlDatesPlugin = app.plugins.getPlugin('nldates-obsidian');
function getNldDate(nlDatesPlugin, dateString) {
let parseResultLink = null;
let parseResult = nlDatesPlugin.parseDate(dateString);
if(parseResult){ parseResultLink = parseResult.formattedString };
if(parseResultLink === "Invalid date") { parseResultLink = null }
View obsidian.templater.editor.selection.turn-into-callout.js
<%*
//Set to false if you do NOT want to ask for a custom title or whether foldable or not
const bCustomTitle = true;
const bFoldable = true;
const calloutOptions = ['note', 'abstract', 'summary', 'tldr', 'info', 'todo', 'tip', 'hint', 'important', 'success', 'check', 'done', 'question', 'help', 'faq', 'warning', 'caution', 'attention', 'failure', 'fail', 'missing', 'danger', 'error', 'bug', 'example', 'quote', 'cite'];
let calloutType = await tp.system.suggester(calloutOptions, calloutOptions, false);
if(!calloutType) { return };
calloutType = calloutType.toUpperCase();
View obsidian.templater.search.section.keyword-journal.js
<%*
const search = app.workspace.getLeavesOfType("search")[0];
let keyword = await tp.system.prompt('Keyword', '[' + '[Journal');
keyword = keyword.replace(/(\[|\])/g, "\\$1");
const searchQuery = `section:(/^#+ ${keyword}.*\\n+\\S[\\s\\S]*[^\\n]/) OR section:(/^#+ ${keyword}.*/ section:(/[\\s\\S]*[^\\n]/))`;
//Collapse=true, Expand=false
search.view.setCollapseAll(false);
//Show Extra Context: true or false
search.view.setExtraContext(false);
//SortOrder Options: alphabeticalReverse, alphabetical, byModifiedTime, byModifiedTimeReverse, byCreatedTime, byCreatedTimeReverse
View obsidian.templater.plugins.hover-editor.tile-popover-windows-grid.js
<%*
//This one tiles popovers with a window grid approach
let hoverPlugin = app.plugins.plugins["obsidian-hover-editor"];
let curPopovers = hoverPlugin ? hoverPlugin.activePopovers : [];
let defaultHeight = "47vh";
let defaultWidth = "32vw";
const defaultLeft = 35;
const defaultTop = 25;
let gridScenario = 1;
View obsidian.templater.operation.change-new-file-location.js
<%*
//Specify your typical default location here so it is always top of the list to reset to
const myDefaultLocation = "new";
//Specify the list of folders you would like to have an option to switch between
const changeToPaths = [myDefaultLocation, 'new/tasks', 'templater', '/'];
const folderTypeSetting = app.vault.getConfig('newFileLocation');
if(folderTypeSetting !== "folder") {
new Notice(`It appears you currently are not using the setting to specify a folder to save new notes to.`, 10000);
} else {
View obsidian.css.templater.query.search-embed-emoji-html-alerts.css
.markdown-source-view.mod-cm6.is-live-preview .cm-preview-code-block .internal-query .search-results-children .query-emoji,
.popover.hover-popover > .markdown-embed .markdown-preview-section .internal-query .search-results-children .query-emoji {
font-size: 2em;
margin-top: 20px;
display: block;
}
.markdown-source-view.mod-cm6.is-live-preview .cm-line .query-emoji > span,
.popover.hover-popover > .markdown-embed .markdown-preview-section > div > :not(.internal-query) .query-emoji > span {
display: none;
}