Skip to content

Instantly share code, notes, and snippets.

@brokosz
Created March 17, 2025 16:38
Show Gist options
  • Save brokosz/ec20f66036acbf53289f00bcfdfbe118 to your computer and use it in GitHub Desktop.
Save brokosz/ec20f66036acbf53289f00bcfdfbe118 to your computer and use it in GitHub Desktop.
# PopClip - Obsidian daily note
name: Obsidian Daily
icon: iconify:majesticons:note-text-plus-line
options:
- identifier: vault
label: Vault Name
type: string
capture html: true
javascript: |
const vaultName = encodeURIComponent(popclip.options.vault);
const todayISO = new Date().toISOString().split('T')[0];
const sanitize = (input) =>
input.replace(/[<>:"/\\|?*\x00-\x1F]/g, '').slice(0, 100);
const generateTitle = (input) => {
let title = input.split('\n').find((line) => line.trim());
return sanitize(title.replace(/[#*_`~>]/g, '').trim());
};
const content = popclip.input.markdown;
const link = popclip.context.browserUrl
? `\n[${popclip.context.browserTitle}](${popclip.context.browserUrl})`
: '';
const clipping = `${content}${link}\n#clipped`;
// Instead of trying to append to a specific heading, use createIfNotExists
// and simply append to the note
popclip.openUrl(
`obsidian://advanced-uri?vault=${vaultName}&daily=true&createIfNotExists=true&data=${encodeURIComponent(clipping)}&mode=append`
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment