Skip to main content
1 / 5

Angular Scully - 自作pluginに対するsetConfigがうまくいきません setConfig not works

自作プラグインに対してsetPluginConfigを呼び出しても反映されません

現在AngularとScullyでブログサイトのSSGに挑戦しています。
力業でアーカイブを作成するプラグインを作成したのですが、
pluginの登録はうまくいきましが
このプラグインに対するsetPluginConfig関数がうまく機能しません

(en) "setPluginConfig" function not works for me.

I made a plugin to generate archive page for blog with scully & angular.
I registered plugin successfully,but failed to inject config files

plugin code

import { HandledRoute, registerPlugin, RouteTypes } from "@scullyio/scully"

export const ARCHIVES_PLUGIN = 'archive'

export interface ArchivePluginConfig {
    root:string;
    articleRoute: string;
    archivePrefixRoute: string;
    archiveSize:number;
}

export const EXAMPLE_CONFIGS: ArchivePluginConfig[] =[{
    root:"/blog",
    articleRoute: "/blog/articles",
    archivePrefixRoute: "/archives",
    archiveSize:8,
}];

export function archivePlugin(routes: HandledRoute[], config?:ArchivePluginConfig[]): Promise<HandledRoute[]> 
{
    console.log(config)//undefinedになります
    config = (config ==undefined || config.length<1)? EXAMPLE_CONFIGS:config;

    config.forEach(config => {       
        //add archives for blog
        let posts = routes.filter((route) => route.route.startsWith(config.articleRoute));
        let archiveCount=Math.floor(posts.length/config.archiveSize)+1;
        
        let archives:HandledRoute[]=[];
        for (let page = 1; page <= archiveCount; page++) {
            archives.push({route:`${config.root}${config.archivePrefixRoute}/${page}`}) 
        }
        archives.forEach(element => {
            routes.push(element);
        });
    });
    return Promise.resolve(routes);
}

registerPlugin("routeProcess", ARCHIVES_PLUGIN, archivePlugin, [])

ScullyConfig

import { ScullyConfig, setPluginConfig } from '@scullyio/scully';
import './scully/plugins/archive';
import { ArchivePluginConfig, ARCHIVES_PLUGIN  ,archivePlugin} from './scully/plugins/archive';

setPluginConfig('md', { enableSyntaxHighlighting: true });

const archiveConfig:ArchivePluginConfig[]=[
  {
    root:"/blog",
    articleRoute:"blog/article",
    archiveSize:8,
    archivePrefixRoute:"/hogeeeeeeeeeee",
  }
]
setPluginConfig<ArchivePluginConfig[]>(ARCHIVES_PLUGIN,'routeProcess',archiveConfig);

const defaultPostRenderers = ['seoHrefOptimise'];

export const config: ScullyConfig = {
  defaultPostRenderers,
  projectRoot: "./",
  projectName: "jl-dotnet",
  outDir: './dist/static',
  routes: {
    '/blog/article/:post': {
      type: 'contentFolder',
      post: {
        folder: "./article/blog"
      }
    },
  }
};

何か見当のつくことや見落としやすい点などありますでしょうか?