Skip to content

Commit

Permalink
chore: fixed metadata route
Browse files Browse the repository at this point in the history
  • Loading branch information
agliga committed Feb 6, 2025
1 parent 102c756 commit bc73da7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
7 changes: 4 additions & 3 deletions src/components/components.marko
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import path from 'path';
import flags from "./data/flags.json"
import icons from "./data/icons.json"

static const componentFolders = import.meta.glob("../routes/_index/component/*/*.marko");
static const componentTemplate = import.meta.glob("../routes/_index/component/*/*.marko", {eager: true});

static const components = Object.keys(componentFolders).map((filePath) => {

static const components = Object.keys(componentTemplate).map((filePath) => {
const parts = filePath.split('/');
return parts.slice(0, parts.length - 1).join('/');
});

export { components, flags, icons };
export { components, componentTemplate, flags, icons };
21 changes: 5 additions & 16 deletions src/routes/metadata/+page.marko
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import path from "path";
import {components} from '../../components/components.marko';
import {componentTemplate} from '../../components/components.marko';

$ const metadata = {}

<for|key, comp| in=components>
$ const componentName = path.basename(comp, '.marko');
$ const name = componentName.replace(/-([a-z])/g, function (g) { return ` ${g[1].toUpperCase()}`; });
$ const rawName = name.charAt(0) + name.slice(1);
/* @TODO Fix this line to result in this structure:
"accordion":{"ds-component":{"name":"accordion","version":1}},"alert-dialog":{"ds-component":{"name":"dialog","version":2.1},"submodules":["button"]},"avatar":{"ds-component":{"name":"avatar","version":1}},"badge":{"ds-component":{"name":"badge","version":1.2}},"breadcrumbs":{"ds-component":{"name":"breadcrumb","version":1.2},"submodules":["icon"]},...

*/
$ metadata[component] = components[rawName];
<!-- $ metadata[component] = components[rawName].metadata; -->
</for>
$ for(let component in componentTemplate) {
const componentName = path.basename(path.dirname(component));
metadata[componentName] = componentTemplate[component].metadata;
}

<!doctype html>
<html lang="en">
Expand All @@ -22,10 +15,6 @@ $ const metadata = {}
</head>

<body>
<h2>Components</h2>
<p>${JSON.stringify(components)}</p>

<h2>Component Metadata</h2>
<p>${JSON.stringify(metadata)}</p>
</body>
</html>

0 comments on commit bc73da7

Please sign in to comment.