Vault on plain .md files with FTS5 index, link rewriting, canvas files, history/trash/backup, link previews, image fetch, tasks and unlinked mentions, Notion/Obsidian importer, quick-capture window and shortcut. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
51 lines
1.8 KiB
JavaScript
51 lines
1.8 KiB
JavaScript
'use strict';
|
|
// First-run content for an empty notes folder.
|
|
const fsp = require('node:fs').promises;
|
|
const path = require('node:path');
|
|
const { today } = require('./vault.cjs');
|
|
|
|
const GETTING_STARTED = `Everything here is plain Markdown in this folder. No account, no sync, nothing leaves this computer.
|
|
|
|
A quiet place to write. Pages nest like folders, tags live in each file's front matter, and search runs against a local index.
|
|
|
|
## Write the way you think
|
|
|
|
- Type \`/\` on any line to add a heading, to-do, quote, toggle or code block.
|
|
- Start a line with \`#\`, \`-\`, \`[]\`, \`>\` or three backticks and it turns into that block as you type.
|
|
- Hover a block and drag the handle on its left to move it.
|
|
- Press <kbd>Ctrl</kbd> <kbd>K</kbd> to search every note or run a command.
|
|
|
|
## First steps
|
|
|
|
- [x] Pick a folder for your notes
|
|
- [ ] Write one page, however short
|
|
- [ ] Try the light theme from the switch in the sidebar
|
|
|
|
<details>
|
|
<summary>Where do my files actually live?</summary>
|
|
|
|
Each page is a \`.md\` file in this folder. A page with sub-pages gets a folder of the same name. The search index sits in \`.notes/index.sqlite\`; delete it any time and it rebuilds on launch.
|
|
|
|
</details>
|
|
|
|
> Notes are for thinking, not for filing.
|
|
`;
|
|
|
|
async function isEmpty(dir) {
|
|
try {
|
|
const entries = await fsp.readdir(dir);
|
|
return entries.filter((n) => !n.startsWith('.')).length === 0;
|
|
} catch (err) {
|
|
if (err.code === 'ENOENT') return true;
|
|
throw err;
|
|
}
|
|
}
|
|
|
|
async function seedVault(dir) {
|
|
await fsp.mkdir(dir, { recursive: true });
|
|
const fm = `---\nicon: sparkle\ncover: blush\ntags: [guide]\ncreated: ${today()}\n---\n\n`;
|
|
await fsp.writeFile(path.join(dir, 'Getting started.md'), fm + GETTING_STARTED, 'utf8');
|
|
}
|
|
|
|
module.exports = { isEmpty, seedVault, GETTING_STARTED };
|