Skip to content

Commit

Permalink
autogenerate index page (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
rambleraptor authored Sep 24, 2024
1 parent 31f5843 commit 1408605
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 47 deletions.
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@astrojs/tailwind": "^5.1.0",
"@hpcc-js/wasm": "^2.22.1",
"astro": "^4.10.2",
"marked": "^14.1.2",
"rehype-graphviz": "^0.3.0",
"sharp": "^0.32.5",
"tailwindcss": "^3.4.10"
Expand Down
34 changes: 33 additions & 1 deletion scripts/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,35 @@ function buildRedirects(aeps: AEP[]): object {
return {};
}

function buildHomepage(): Markdown {
let frontmatter = {
"title": "AEPs",
"description": "Application Enhancement Proposals",
"template": "splash",
"hero": {
"tagline": "Focused design documents for flexible API development.",
"image": {
"file": "../../assets/aep.svg"
},
actions: []
},
}

let config = loadConfigFiles("hero.yaml");
frontmatter.hero.actions = config.hero.buttons.map((button) => ({text: button.text, link: button.href, icon: "right-arrow"}));

let contents = `import config from "../../../generated/config.json";
<HomeGrid sections={config.hero.shortcuts} />
`
let markdown = new Markdown(contents, frontmatter);
markdown.addComponent({
"names": ["HomeGrid"],
"path": "../../components/HomeGrid.astro"
});
return markdown;
}

// Build config.
let config = loadConfigFiles("hero.yaml", "urls.yaml", "site.yaml");
writeSidebar(config, "config.json");
Expand Down Expand Up @@ -281,4 +310,7 @@ var linter_sidebar = buildLinterSidebar(consolidated_rules);
writeSidebar(linter_sidebar, "linter_sidebar.json");

buildIndexPage(aeps);
writeSidebar(buildRedirects(aeps), "redirects.json");
writeSidebar(buildRedirects(aeps), "redirects.json");

let homePage = buildHomepage();
fs.writeFileSync("src/content/docs/index.mdx", homePage.build());
15 changes: 15 additions & 0 deletions src/components/HomeGrid.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
const {sections} = Astro.props;
import { Card, CardGrid, LinkButton } from '@astrojs/starlight/components';
import { marked } from 'marked';
---
<CardGrid>
{sections.map((section) => (
<Card title={section.title}>
<article set:html={marked.parse(section.description)} />


<LinkButton href={section.button.href}>{section.button.text}</LinkButton>
</Card>
))}
</CardGrid>
46 changes: 0 additions & 46 deletions src/content/docs/index.mdx

This file was deleted.

0 comments on commit 1408605

Please sign in to comment.