mirror of
https://github.com/bramses/bramses-highly-opinionated-vault-2023.git
synced 2025-02-26 07:53:55 +00:00
vault backup: 2022-12-17 17:29:16
This commit is contained in:
38
_scripts/move-zettel-to-private.js
Normal file
38
_scripts/move-zettel-to-private.js
Normal file
@@ -0,0 +1,38 @@
|
||||
module.exports = async function moveZettel(params) {
|
||||
const PRIVATE_FOLDER = "Private/";
|
||||
const Notice = params.obsidian.Notice;
|
||||
|
||||
|
||||
|
||||
// get active file
|
||||
const activeFile = params.app.workspace.getActiveFile();
|
||||
const activeFileName = activeFile.basename;
|
||||
const activeFileFolder = activeFile.parent.path;
|
||||
const activeFileExt = activeFile.extension;
|
||||
|
||||
|
||||
|
||||
if (activeFileFolder === PRIVATE_FOLDER) {
|
||||
new Notice("File is already in private folder");
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeFileExt !== "md") {
|
||||
new Notice("File is not a markdown file");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// log active file info
|
||||
console.log(activeFileFolder);
|
||||
console.log(activeFileName);
|
||||
console.log(activeFileExt);
|
||||
|
||||
|
||||
|
||||
// move file to private folder
|
||||
await params.app.vault.rename(
|
||||
activeFile,
|
||||
`${PRIVATE_FOLDER}${activeFileName}.${activeFileExt}`
|
||||
);
|
||||
}
|
||||
@@ -48,6 +48,20 @@ tags: [projects, ${userInput.replace(/ /g, "-")}]
|
||||
---\n\n\`\`\`dataview
|
||||
list
|
||||
where contains(projects, "${userInput.replace(/ /g, "-")}")
|
||||
\`\`\`\n\n
|
||||
|
||||
>[!info]
|
||||
> The following code block allows you to "freeze" the Dataview query result above into HTML.
|
||||
> If you use Obsidian Publish, this will allow you to publish the resource list as it is above.
|
||||
> I recommend running this, **after** you finish a project and are ready to commit it to _PARA/Archive.
|
||||
> To use: open command pallette, remove the spaces between < % and *, run "Templater: Replace all templates in Active File", and remove the triple backticks.
|
||||
|
||||
\`\`\`
|
||||
< % *
|
||||
const dv = this.app.plugins.plugins["dataview"].api ;
|
||||
const arr = await dv.queryMarkdown(\`LIST where contains(projects, "${userInput}")\`)
|
||||
tR += arr.value
|
||||
% >
|
||||
\`\`\`\n\n`
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user