diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-02-11 09:51:56 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-02-12 07:43:55 -0400 |
commit | bdef19f601a11c25e8d58b56d7f8135a94722505 (patch) | |
tree | 2ce9840ff375cf0c0824c99f839793e15865fca7 /src/content/dependencies/generateWikiHomepagePage.js | |
parent | 0eb70fd321af7bd2a52ea5b8a614321397f794c0 (diff) |
content: generateWikiHome -> generateWikiHomepage, etc
Diffstat (limited to 'src/content/dependencies/generateWikiHomepagePage.js')
-rw-r--r-- | src/content/dependencies/generateWikiHomepagePage.js | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/src/content/dependencies/generateWikiHomepagePage.js b/src/content/dependencies/generateWikiHomepagePage.js new file mode 100644 index 00000000..73ab5dd4 --- /dev/null +++ b/src/content/dependencies/generateWikiHomepagePage.js @@ -0,0 +1,116 @@ +export default { + contentDependencies: [ + 'generatePageLayout', + 'generatePageSidebar', + 'generatePageSidebarBox', + 'generateWikiHomepageAlbumsRow', + 'generateWikiHomepageNewsBox', + 'transformContent', + ], + + extraDependencies: ['wikiData'], + + sprawl({wikiInfo}) { + return { + wikiName: wikiInfo.name, + + enableNews: wikiInfo.enableNews, + }; + }, + + relations(relation, sprawl, homepageLayout) { + const relations = {}; + + relations.layout = + relation('generatePageLayout'); + + relations.sidebar = + relation('generatePageSidebar'); + + if (homepageLayout.sidebarContent) { + relations.customSidebarBox = + relation('generatePageSidebarBox'); + + relations.customSidebarContent = + relation('transformContent', homepageLayout.sidebarContent); + } + + if (sprawl.enableNews) { + relations.newsSidebarBox = + relation('generateWikiHomepageNewsBox'); + } + + if (homepageLayout.navbarLinks) { + relations.customNavLinkContents = + homepageLayout.navbarLinks + .map(content => relation('transformContent', content)); + } + + relations.contentRows = + homepageLayout.rows.map(row => { + switch (row.type) { + case 'albums': + return relation('generateWikiHomepageAlbumsRow', row); + default: + return null; + } + }); + + return relations; + }, + + data(sprawl) { + return { + wikiName: sprawl.wikiName, + }; + }, + + generate(data, relations) { + return relations.layout.slots({ + title: data.wikiName, + showWikiNameInTitle: false, + + mainClasses: ['top-index'], + headingMode: 'static', + + mainContent: [ + relations.contentRows, + ], + + leftSidebar: + relations.sidebar.slots({ + wide: true, + + boxes: [ + relations.customSidebarContent && + relations.customSidebarBox.slots({ + attributes: {class: 'custom-content-sidebar-box'}, + collapsible: false, + + content: + relations.customSidebarContent + .slot('mode', 'multiline'), + }), + + relations.newsSidebarBox, + ], + }), + + navLinkStyle: 'index', + navLinks: [ + {auto: 'home', current: true}, + + ...( + relations.customNavLinkContents + ?.map(content => ({ + html: + content.slots({ + mode: 'single-link', + preferShortLinkNames: true, + }), + })) + ?? []), + ], + }); + }, +}; |