0.0.29
This commit is contained in:
@@ -2,6 +2,7 @@ import {
|
||||
flashNotification,
|
||||
getText,
|
||||
} from "@silverbulletmd/plugos-silverbullet-syscall/editor";
|
||||
import { listPages } from "@silverbulletmd/plugos-silverbullet-syscall/space";
|
||||
|
||||
function countWords(str: string): number {
|
||||
const matches = str.match(/[\w\d\'-]+/gi);
|
||||
@@ -15,7 +16,10 @@ function readingTime(wordCount: number): number {
|
||||
|
||||
export async function statsCommand() {
|
||||
const text = await getText();
|
||||
const allPages = await listPages();
|
||||
const wordCount = countWords(text);
|
||||
const time = readingTime(wordCount);
|
||||
await flashNotification(`${wordCount} words, ${time} minutes to read.`);
|
||||
await flashNotification(
|
||||
`${wordCount} words; ${time} minutes read; ${allPages.length} total pages in space.`
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user