Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more Local options in codeblock (ignore, limit, etc) #94

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,53 @@ You can also use the ``folder-index-content`` Block processor directly like this
```
````

to include the content of the folder index in any note you want
to include the content of the folder index in any note you want.

#### Frontmatter

| Key | Description |
|-------|---------------------------------------------------|
| title | This will overwrite the Filename inside the Index |

### Code Block Configuration

The `folder-index-content` code block supports the following configuration options:

| Option | Description | Example |
|--------|-------------|---------|
| title | This will overwrite the Filename inside the Index | `title: My Custom Title` |
| ignore | Files/folders to exclude from the content (supports wildcards) | `ignore: *.pdf, *img*, temp` |
| recursionLimit | Override the global subfolder limit for this index | `recursionLimit: 2` |

Example:
````md
```folder-index-content
title: Project Files
ignore: *.pdf, *img*, temp, Folder/
recursionLimit: 2
```
````

The `ignore` option supports:
- Multiple patterns separated by commas
- Wildcards using `*` (e.g., `*.pdf` to exclude all PDF files)
- This works in addition to the global exclude patterns in the plugin settings

### Settings

| Setting | Description |
|---------|-------------|
| Graph View | Overwrite the default graph view to show folder structure |
| Root Index File | The file used for the root index |
| Initial Content | Default content for new folder indexes |
| Excluded Folders | Folders that won't create index files automatically |
| Excluded Patterns | Files/folders to exclude from content (supports wildcards) |
| Only Show Markdown Files | When enabled, only markdown files will be shown in indexes |
| Auto Generate Index | Create index files automatically for new folders |
| Auto Rename Index | Rename index files when folders are renamed |
| User Defined Index Name | Use a custom name for index files |
| Index Filename | The custom filename for indexes |

### Manual Installation

1. Go to [Releases](https://github.com/turulix/obsidian-folder-index/releases) and download the ZIP file from the latest
Expand Down
6 changes: 2 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export default class FolderIndexPlugin extends Plugin {
this.registerEvent(this.app.workspace.on("layout-change", this.onLayoutChange.bind(this)))
this.eventManager.on("settingsUpdate", this.onSettingsUpdate.bind(this))

this.registerMarkdownCodeBlockProcessor("folder-index-content", (_source, el, ctx) => {
ctx.addChild(new IndexContentProcessorModule(this.app, this, ctx.sourcePath, el))
this.registerMarkdownCodeBlockProcessor("folder-index-content", (source, el, ctx) => {
ctx.addChild(new IndexContentProcessorModule(this.app, this, ctx.sourcePath, el, source))
})

this.folderNodeModule = new FolderNoteModule(this.app, this)
Expand Down Expand Up @@ -96,5 +96,3 @@ export default class FolderIndexPlugin extends Plugin {
this.eventManager.emit("settingsUpdate", this.settings);
}
}


6 changes: 6 additions & 0 deletions src/models/CodeBlockConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface CodeBlockConfig {
title?: string;
type?: string;
ignore?: string[];
recursionLimit?: number; // 本地递归层级限制
}
51 changes: 36 additions & 15 deletions src/models/PluginSettingsTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export interface PluginSetting {
headlineLimit: number;
indexFileUserSpecified: boolean;
indexFilename: string;
markdownOnly: boolean;
onlyOpenIndexByName: boolean;
}

export const DEFAULT_SETTINGS: PluginSetting = {
Expand All @@ -61,7 +63,9 @@ export const DEFAULT_SETTINGS: PluginSetting = {
recursionLimit: -1,
headlineLimit: 6,
indexFileUserSpecified: false,
indexFilename: "!"
indexFilename: "!",
markdownOnly: false,
onlyOpenIndexByName: false
}

export class PluginSettingsTab extends PluginSettingTab {
Expand Down Expand Up @@ -139,20 +143,6 @@ export class PluginSettingsTab extends PluginSettingTab {
component.inputEl.cols = 50
})

new Setting(containerEl)
.setName("Excluded Patterns")
.setDesc("Files and folders matching these patterns will be excluded from the content renderer. Use * as wildcard. One pattern per line.")
.addTextArea(component => {
component.setPlaceholder("Assets\n*img*\n*.pdf")
.setValue(this.plugin.settings.excludePatterns.join("\n"))
.onChange(async (value) => {
this.plugin.settings.excludePatterns = value.split("\n")
await this.plugin.saveSettings()
})
component.inputEl.rows = 8
component.inputEl.cols = 50
})

new Setting(containerEl)
.setName("Automatically generate IndexFile")
.setDesc("This will automatically create an IndexFile when you create a new folder")
Expand Down Expand Up @@ -203,6 +193,29 @@ export class PluginSettingsTab extends PluginSettingTab {

containerEl.createEl('h2', {text: 'Content Renderer Settings'});

new Setting(containerEl)
.setName("Only Show Markdown Files")
.setDesc("When enabled, only markdown files will be shown in the index")
.addToggle(component => component.setValue(this.plugin.settings.markdownOnly)
.onChange(async (value) => {
this.plugin.settings.markdownOnly = value
await this.plugin.saveSettings()
}))

new Setting(containerEl)
.setName("Excluded Patterns")
.setDesc("Files and folders matching these patterns will be excluded from the content renderer. Use * as wildcard. One pattern per line.")
.addTextArea(component => {
component.setPlaceholder("Assets\n*img*\n*.pdf")
.setValue(this.plugin.settings.excludePatterns.join("\n"))
.onChange(async (value) => {
this.plugin.settings.excludePatterns = value.split("\n")
await this.plugin.saveSettings()
})
component.inputEl.rows = 8
component.inputEl.cols = 50
})

// new Setting(containerEl)
// .setName("Skip First Headline")
// .setDesc("This Option should not be used anymore, as Obsidian now shows the Filename itself " +
Expand Down Expand Up @@ -353,5 +366,13 @@ export class PluginSettingsTab extends PluginSettingTab {
await this.plugin.saveSettings()
}))

new Setting(containerEl)
.setName("Only Open Index By Name")
.setDesc("This will only open index files by name")
.addToggle(component => component.setValue(this.plugin.settings.onlyOpenIndexByName)
.onChange(async (value) => {
this.plugin.settings.onlyOpenIndexByName = value
await this.plugin.saveSettings()
}))
}
}
Loading
Loading