Skip to content

Commit

Permalink
feat: update plugin template string
Browse files Browse the repository at this point in the history
  • Loading branch information
danpacho committed Aug 21, 2024
1 parent 2244092 commit b466f4d
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,43 @@
// Build contents plugin template
// -------------------------------------------------------------- //

import { Builder, Plugin } from '@obsidian_blogger/build_system'
import { Plugin } from '@obsidian_blogger/build_system'

export interface {{plugin_name}}Options {
option1: string
option2: string
export type {{plugin_name}}StaticConfig = Plugin.BuildContentsPluginStaticConfig & {
static1: string
static2: string
}
export class {{plugin_name}}Plugin extends Plugin.BuildContentsPlugin {
public constructor(private readonly options: {{plugin_name}}Options) {
super()
}

public getConfig(): Plugin.BuildContentsPluginConfig {
export type {{plugin_name}}DynamicConfig = Plugin.BuildContentsDynamicConfig & {
dynamicProperty?: string
}
export class {{plugin_name}}Plugin extends Plugin.BuildContentsPlugin<
{{plugin_name}}StaticConfig,
{{plugin_name}}DynamicConfig
> {
public defineStaticConfig(): {{plugin_name}}StaticConfig {
return {
name: '{{plugin_name}}',
disableCache: false,
description: '{{plugin_name}} plugin description',
// If you want to add a user-input based configuration, you can define it here
dynamicConfigSchema: {
dynamicProperty: {
type: 'string',
description: 'dynamic1 description',
defaultValue: 'default value for dynamic1',
optional: true,
},
},
// user-defined static configuration
static1: 'static1',
static2: 'static2',
}
}

public async buildContents(context: {
buildStore: Builder.BuildStoreList
}): Promise<Array<{ newContent: string; writePath: string }>> {
public async buildContents({
buildStore,
}: Parameters<Plugin.BuildContentsPlugin['buildContents']>[0]): Promise<
Array<{ newContent: string; writePath: string }>
> {
// Implement the buildContents logic here
return []
}
}
}
45 changes: 28 additions & 17 deletions packages/cli/src/template/plugin/build/ts/build:tree/template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,42 @@
// Build tree plugin template
// -------------------------------------------------------------- //

import { Node, Plugin } from '@obsidian_blogger/build_system'
import { Plugin } from '@obsidian_blogger/build_system'

export interface {{plugin_name}}Options {
option1: string
option2: string
export type {{plugin_name}}StaticConfig = Plugin.BuildTreePluginStaticConfig & {
static1: string
static2: string
}
export class {{plugin_name}}Plugin extends Plugin.BuildTreePlugin {
public constructor(private readonly options: {{plugin_name}}Options) {
super()
}

public getConfig(): Plugin.BuildTreePluginConfig {
export type {{plugin_name}}DynamicConfig = Plugin.BuildTreePluginDynamicConfig & {
dynamicProperty?: string
}
export class {{plugin_name}}Plugin extends Plugin.BuildTreePlugin<
{{plugin_name}}StaticConfig,
{{plugin_name}}DynamicConfig
> {
public defineStaticConfig(): {{plugin_name}}StaticConfig {
return {
name: '{{plugin_name}}',
disableCache: false,
exclude: [],
skipFolderNode: true,
description: '{{plugin_name}} plugin description',
// If you want to add a user-input based configuration, you can define it here
dynamicConfigSchema: {
dynamicProperty: {
type: 'string',
description: 'dynamic1 description',
defaultValue: 'default value for dynamic1',
optional: true,
},
},
// user-defined static configuration
static1: 'static1',
static2: 'static2',
}
}

public async walk(
node: Node.FTreeNode,
i: number,
peerNodes: Array<Node.FTreeNode>
node: Parameters<Plugin.BuildTreePlugin['walk']>[0],
context: Parameters<Plugin.BuildTreePlugin['walk']>[1]
): Promise<void> {
return
// Implement the build logic here
}
}
61 changes: 36 additions & 25 deletions packages/cli/src/template/plugin/build/ts/walk:tree/template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,42 @@
// Walk tree plugin template
// -------------------------------------------------------------- //

import { Node, Plugin } from '@obsidian_blogger/build_system'
import { Plugin } from "@obsidian_blogger/build_system";

export interface {{plugin_name}}Options {
option1: string
option2: string
}
export class {{plugin_name}}Plugin extends Plugin.BuildTreePlugin {
public constructor(private readonly options: {{plugin_name}}Options) {
super()
}

public getConfig(): Plugin.BuildTreePluginConfig {
return {
name: '{{plugin_name}}',
disableCache: false,
exclude: [],
skipFolderNode: true,
}
}
export type {{plugin_name}}StaticConfig = Plugin.WalkTreePluginStaticConfig & {
static1: string;
static2: string;
};
export type {{plugin_name}}DynamicConfig = Plugin.WalkTreePluginDynamicConfig & {
dynamicProperty?: string;
};
export class {{plugin_name}}Plugin extends Plugin.WalkTreePlugin<
{{plugin_name}}StaticConfig,
{{plugin_name}}DynamicConfig
> {
public defineStaticConfig(): {{plugin_name}}StaticConfig {
return {
name: "{{plugin_name}}",
description: "{{plugin_name}} plugin description",
// If you want to add a user-input based configuration, you can define it here
dynamicConfigSchema: {
dynamicProperty: {
type: "string",
description: "dynamic1 description",
defaultValue: "default value for dynamic1",
optional: true,
},
},
// user-defined static configuration
static1: "static1",
static2: "static2",
};
}

public async walk(
node: Node.FTreeNode,
i: number,
peerNodes: Array<Node.FTreeNode>
): Promise<void> {
return
}
public async walk(
node: Parameters<Plugin.WalkTreePlugin["walk"]>[0],
context: Parameters<Plugin.WalkTreePlugin["walk"]>[1]
): Promise<void> {
// Implement the walk logic here
}
}

0 comments on commit b466f4d

Please sign in to comment.