Skip to content

Commit

Permalink
Merge pull request #221 from snezhig/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
snezhig authored Aug 12, 2024
2 parents 743384b + 1a2a3cc commit 5674a42
Show file tree
Hide file tree
Showing 20 changed files with 4,017 additions and 6,890 deletions.
21 changes: 12 additions & 9 deletions config/services/processors.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { ContainerModule } from "inversify";
import { ContainerModule } from "inversify";
import SI from "../inversify.types";
import { KeyStorageInterface } from "../../src/Storage/Interfaces";
import { SettingsType } from "../../src/Settings/SettingsType";
import ReplaceProcessor from "../../src/Components/Processor/ReplaceProcessor";
import FunctionProcessor from "../../src/Components/Processor/FunctionProcessor";
import { ProcessorTypes } from "../../src/Components/Processor/ProcessorUtils";
import { KeyStorageInterface } from "@src/Storage/Interfaces";
import { SettingsType } from "@src/Settings/SettingsType";
import ReplaceProcessor from "@src/Components/Processor/ReplaceProcessor";
import FunctionProcessor from "@src/Components/Processor/FunctionProcessor";
import { ProcessorTypes } from "@src/Components/Processor/ProcessorUtils";
import FunctionV2Processor from "@src/Components/Processor/FunctionV2Processor";

export default new ContainerModule(bind => {
bind(SI.processor).to(ReplaceProcessor).whenTargetNamed(ProcessorTypes.Replace);
bind(SI.processor).to(FunctionProcessor).whenTargetNamed(ProcessorTypes.Function);
bind(SI["processor:args"]).toDynamicValue(c => c.container.get<KeyStorageInterface<SettingsType>>(SI["settings:storage"]).get('processor').get('args').value())
bind(SI.processor).to(FunctionV2Processor).whenTargetNamed(ProcessorTypes.FunctionV2);
bind(SI["processor:args"]).toDynamicValue(c =>
c.container.get<KeyStorageInterface<SettingsType>>(SI["settings:storage"]).get("processor").get("args").value()
);
bind(SI["factory:processor"]).toAutoNamedFactory(SI.processor);
});


22 changes: 22 additions & 0 deletions docs/Processor.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,25 @@ You can read more about this
logic [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
Inside your function you will be able to use `title` variable which contains resolved title.
A value returned by your function will be used as shown title

## FunctionV2

Works same as [Function](#function), but the argument is the object instead of string;
Object your function will give an argument:
```typescript
// Object that will be given into FunctionV2 processor as an "obj" argument
export type FunctionV2ObjArg = {
// New file title
title: string;
// Path to file
path: string;
};
```

Example of text area:
```typescript
//just for debugging
console.debug(obj)

return obj.title + '-title-in-' + obj.path
```
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-front-matter-title-plugin",
"name": "Front Matter Title",
"version": "3.9.0",
"version": "3.10.0",
"minAppVersion": "1.5.3",
"description": "Lets you define a title in frontmatter to be displayed as the filename for explorer, graph, search and etc.",
"author": "Snezhig",
Expand Down
Loading

0 comments on commit 5674a42

Please sign in to comment.