Created
March 17, 2025 16:38
-
-
Save brokosz/ec20f66036acbf53289f00bcfdfbe118 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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