I'm trying to launch a blog as a static site using Angular and Scully modules.
I implemented the automatic generation of archive pages as a plug-in, but the setConfig function may not work well.
Learn how to configure plug-ins from non-plug-in scripts
I think there is something wrong, but it has not been resolved at all.
Please let me know if there is anything I should check or easily miss.
What I could do:
Problem:
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;
}
// First, define the config as a constant in the plugin file
export const EXAMPLE_CONFIGS: ArchivePluginConfig[] = [{
root: "/blog",
articleRoute: "/blog/articles",
archivePrefixRoute: "/archives",
archiveSize—8,
}];
export function archivePlugin(routes:HandledRoute[], config?:ArchivePluginConfig[]):Promise <HandledRoute[]>{
// Undefined or check if elements exist in the array and decide whether to apply the previous configuration
// If you use console.log(config) before running this line next time, undefined appears.
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));
letarchiveCount=Math.floor(posts.length/config.archiveSize)+1;
letarchives —HandledRoute[]=[];
for (let page=1; page<=archiveCount;page++){
archive.push({route:`${config.root}${config.archivePrefixRoute}/${page}`})
}
archives.forEach(element=>{
routes.push(element);
});
});
return Promise.resolve(routes);
}
registerPlugin("routeProcess", ARCHIVES_PLUGIN, archivePlugin, [ ])
scully.{myproject}.config.tscode:
import {ScullyConfig, setPluginConfig} from '@scullyio/scully';
import'./scully/plugins/archive';
import {ArchivePluginConfig, ARCHIVES_PLUGIN, archivePlugin} from'./scully/plugins/archive';
setPluginConfig('md', {enableSyntaxHighlighting:true});
conformConfig —ArchivePluginConfig[] = [
{
root: "/blog",
articleRoute: "blog/article",
archiveSize—8,
archivePrefixRoute: "/articles",
}
]
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"
}
},
}
};
environment, etc.:
OS:windows10
editor:vscode
console:git-bash
nodejs:v14.16.1
npm:7.12.0
A project created about a week ago about 2021/5/4
Create a project from IangularCli
Install scullyio through npm
OS:windows10
editor:vscode
console:git-bash
nodejs —v14.16.1
npm:7.12.0
Project created about a week ago 2021/5/4
Create a project from IangularCli
Install scullyio through npm
The settings for the plug-in created by someone else are working well.
For example, the following configuration will cause syntax highlights to markdown
setPluginConfig('md', {enableSyntaxHighlighting:true});
I am writing this site with a friend, but it is difficult for two people to solve it on their own, so this is my first time posting a question.We do not have much information in Japanese on the scale itself, so please forgive us for double posting with the English version of stackoverflow.
typescript markdown angular
Resolved
Now it worked
© 2024 OneMinuteCode. All rights reserved.