Skip to content

Commit

Permalink
New Settings to filter note content based on regex (#166)
Browse files Browse the repository at this point in the history
* Update NotePreview.tsx to remove code blocks

Code blocks often cause errors on "On This Day" page, hence strip them out

* feat: new setting to filter note content based on regex

* chore: version

* chore: prettier and remove deprecated .eslintignore

* chore: fix release workflow

---------

Co-authored-by: Dr. Tarique Sani <[email protected]>
  • Loading branch information
Kageetai and tariquesani authored Oct 22, 2024
1 parent 232fbc0 commit 0f4d109
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 12 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ jobs:
uses: ncipollo/[email protected]
with:
artifacts: "dist/**/*"
generate_release_notes: true
generateReleaseNotes: true
draft: true
token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ main.js
data.json
workspace.json
vault/**/*.md
vault/.obsidian/plugins/*
!vault/.obsidian/plugins/journal-review
vault/.obsidian/plugins/

# Exclude macOS Finder (System Explorer) View States
.DS_Store
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "journal-review",
"name": "Journal Review",
"version": "2.4.0",
"version": "2.4.1",
"minAppVersion": "0.15.0",
"description": "Review your daily notes on their anniversaries, like \"what happened today last year\".",
"author": "Kageetai",
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-plugin-journal-review",
"version": "2.4.0",
"version": "2.4.1",
"description": "Review your daily notes on their anniversaries, like \"what happened today last year\"\n\n",
"main": "main.js",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions src/components/NotePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const NotePreview = ({ note }: Props) => {
const slicedContent = (await app.vault.cachedRead(note))
// remove frontmatter
.replace(/---.*?---/s, "")
// remove custom regex
.replace(new RegExp(settings.noteMarkdownRegex, "sg"), "")
// restrict to chosen preview length
.substring(0, settings.previewLength);

Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface Settings {
useNotifications: boolean;
renderOnFileSwitch: boolean;
date: string;
noteMarkdownRegex: string;
}

export const DEFAULT_SETTINGS: Settings = {
Expand All @@ -66,6 +67,7 @@ export const DEFAULT_SETTINGS: Settings = {
useNotifications: true,
renderOnFileSwitch: false,
date: "",
noteMarkdownRegex: "",
};

export const getTimeSpanTitle = ({ number, unit, recurring }: TimeSpan) =>
Expand Down
14 changes: 14 additions & 0 deletions src/settingsTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,5 +245,19 @@ export class SettingsTab extends PluginSettingTab {
void this.plugin.saveSettings();
});
});

new Setting(containerEl)
.setName("Note filtering regex")
.setDesc(
"Use any string or regex (without `/` at beginning and end or flags) to filter the note content before rendering.",
)
.addText((text) =>
text
.setValue(this.plugin.settings.noteMarkdownRegex)
.onChange((value) => {
this.plugin.settings.noteMarkdownRegex = value;
void this.plugin.saveSettings();
}),
);
}
}
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"2.3.0": "0.15.0",
"2.3.1": "0.15.0",
"2.3.2": "0.15.0",
"2.4.0": "0.15.0"
"2.4.0": "0.15.0",
"2.4.1": "0.15.0"
}

0 comments on commit 0f4d109

Please sign in to comment.