22 * @ifla /preset-ifla
33 *
44 * Official IFLA Docusaurus preset for standards sites.
5- * Provides standardized configuration, navigation, and theme setup
6- * for all IFLA standards documentation sites.
5+ * Provides standardized plugins and themes for all IFLA documentation sites.
76 */
87
9- import type { LoadContext } from '@docusaurus/types' ;
10- import type { IFLAPresetOptions , IFLAPresetFunction } from './types' ;
11- import { getCurrentEnv , mergeVocabularyDefaults } from './utils' ;
12- import { buildThemeConfig } from './theme' ;
13- import { getPlugins , getThemes , createWebpackConfig , createSidebarGenerator } from './plugins' ;
8+ import type { LoadContext , Preset } from '@docusaurus/types' ;
149
1510/**
1611 * IFLA Docusaurus Preset
1712 *
1813 * This preset provides:
19- * - Complete site configuration with cross-site navigation
20- * - Vocabulary defaults for shared components
21- * - Standard theme configuration and plugins
22- * - Proper customFields setup for component compatibility
14+ * - Standard plugins (sass, ideal-image, search)
15+ * - No navigation or theme configuration (handled by sites)
2316 *
2417 * @param context Docusaurus LoadContext
25- * @param options IFLAPresetOptions
26- * @returns Complete Docusaurus configuration
18+ * @param options Options passed to the preset
19+ * @returns Docusaurus preset configuration
2720 */
28- const preset : IFLAPresetFunction = function (
21+ export default function preset (
2922 context : LoadContext ,
30- options : IFLAPresetOptions
31- ) {
32- const {
33- siteKey,
34- title,
35- tagline,
36- url,
37- baseUrl,
38- projectName = siteKey ,
39- env,
40- vocabularyDefaults,
41- // customNavbarItems, navigation, footer - DEPRECATED: ignored, use docusaurus.config.factory.ts
42- editUrl,
43- // additionalPlugins = [], // TODO: implement when needed
44- // redirects, // TODO: implement when needed
45- overrides = { } ,
46- customSidebarGenerator = false ,
47- i18n,
48- webpackConfig,
49- // enableIdealImage, // TODO: implement when needed
50- // enableLiveCodeblock, // TODO: implement when needed
51- // enableLocalSearch, // TODO: implement when needed
52- enableMermaid,
53- docsPluginOptions = { } ,
54- blogPluginOptions = { } ,
55- prismTheme,
56- prismDarkTheme,
57- } = options ;
58-
59- // Resolve environment (still needed for navigation links)
60- const resolvedEnv = env ?? getCurrentEnv ( ) ;
61-
62- // Merge vocabulary defaults with user overrides
63- const mergedVocabularyDefaults = mergeVocabularyDefaults ( vocabularyDefaults ) ;
64-
65- // Build base theme configuration (no navbar/footer - those are built in individual site configs)
66- const themeConfig = buildThemeConfig (
67- prismTheme ,
68- prismDarkTheme ,
69- enableMermaid
70- ) ;
71-
72- // Build docs plugin options
73- const docsOptions = {
74- sidebarPath : './sidebars.ts' ,
75- editUrl : editUrl || `https://github.com/iflastandards/standards-dev/tree/main/` ,
76- showLastUpdateAuthor : docsPluginOptions . showLastUpdateAuthor ?? true ,
77- showLastUpdateTime : docsPluginOptions . showLastUpdateTime ?? true ,
78- sidebarItemsGenerator : createSidebarGenerator ( customSidebarGenerator ) ,
79- versions : docsPluginOptions . versions || {
80- current : {
81- label : 'Latest' ,
82- } ,
83- } ,
84- } ;
85-
86- // Build blog plugin options
87- const blogOptions = {
88- showReadingTime : true ,
89- feedOptions : {
90- type : blogPluginOptions . feedOptions ?. type || 'all' ,
91- xslt : blogPluginOptions . feedOptions ?. xslt ?? true ,
92- copyright : blogPluginOptions . feedOptions ?. copyright || `Copyright © ${ new Date ( ) . getFullYear ( ) } IFLA` ,
93- } ,
94- onInlineAuthors : 'ignore' ,
95- onInlineTags : 'warn' ,
96- onUntruncatedBlogPosts : 'ignore' ,
97- } ;
98-
99- // Base configuration
100- const baseConfig = {
101- title,
102- tagline,
103- url,
104- baseUrl,
105- projectName,
106- organizationName : 'iflastandards' ,
107- staticDirectories : [ 'static' , '../../packages/theme/static' ] ,
108-
109- // Future flags
110- future : {
111- experimental_faster : false ,
112- experimental_storage : {
113- type : 'localStorage' ,
114- namespace : true ,
115- } ,
116- experimental_router : 'browser' ,
117- } ,
118-
119- // Error handling
120- onBrokenLinks : overrides ?. onBrokenLinks || 'warn' ,
121- onBrokenAnchors : overrides ?. onBrokenAnchors || 'warn' ,
122- onBrokenMarkdownLinks : overrides ?. onBrokenMarkdownLinks || 'warn' ,
123- onDuplicateRoutes : 'warn' ,
124-
125- // Markdown configuration
126- markdown : {
127- format : 'mdx' ,
128- mermaid : enableMermaid || false ,
129- preprocessor : ( { fileContent } : { filePath : string ; fileContent : string } ) => {
130- return fileContent ;
131- } ,
132- mdx1Compat : {
133- comments : true ,
134- admonitions : true ,
135- headingIds : true ,
136- } ,
137- } ,
138-
139- // i18n configuration
140- i18n : i18n || {
141- defaultLocale : 'en' ,
142- locales : [ 'en' ] ,
143- } ,
144- } ;
145-
146- // Build complete configuration
23+ options : any
24+ ) : Preset {
14725 return {
148- ...baseConfig ,
149- presets : [
26+ themes : [ ] ,
27+
28+ plugins : [
29+ // Sass support
30+ require . resolve ( 'docusaurus-plugin-sass' ) ,
31+
32+ // Ideal image optimization
15033 [
151- '@docusaurus/preset-classic' ,
34+ require . resolve ( '@docusaurus/plugin-ideal-image' ) ,
15235 {
153- docs : docsOptions ,
154- blog : blogOptions ,
155- theme : {
156- customCss : './src/css/custom.css' ,
157- } ,
36+ quality : 70 ,
37+ max : 1030 ,
38+ min : 640 ,
39+ steps : 2 ,
40+ disableInDev : false ,
41+ } ,
42+ ] ,
43+
44+ // Local search functionality
45+ [
46+ require . resolve ( '@easyops-cn/docusaurus-search-local' ) ,
47+ {
48+ hashed : true ,
49+ indexBlog : false ,
50+ language : [ 'en' ] ,
15851 } ,
15952 ] ,
16053 ] ,
161- plugins : getPlugins ( options ) ,
162- themes : getThemes ( options ) ,
163- themeConfig,
164- customFields : {
165- vocabularyDefaults : mergedVocabularyDefaults ,
166- elementDefaults : mergedVocabularyDefaults . elementDefaults ,
167- docsEnv : resolvedEnv ,
168- } ,
169- ...overrides ,
170- // Apply webpack config if provided
171- ...( webpackConfig && {
172- configureWebpack : createWebpackConfig ( webpackConfig ) ,
173- } ) ,
17454 } ;
175- } ;
176-
177- export default preset ;
178-
179- // Export helper functions for consumer use
180- export { getSiteConfig } from './utils' ;
181-
182- // Export types for consumer use
183- export type { IFLAPresetOptions } from './types' ;
55+ }
0 commit comments