diff --git a/components/builder-helper.tsx b/components/builder-helper.tsx
index ff60f92..e42c108 100644
--- a/components/builder-helper.tsx
+++ b/components/builder-helper.tsx
@@ -1,17 +1,33 @@
import badgeList from '../public/.meta/badge-list.json'
+import badgeListLegacy from '../public/.meta/badges.json'
// const examples = [...badgeList.live, ...badgeList.static].reduce((accu, curr) => {
// return (accu as any).concat(Object.entries(curr.examples))
// }, [] as [string, string][])
-type Examples = [string, string][]
+type BadgeExamples = {
+ [pathname: string]: string
+}
+type BadgeList = {
+ [id: string]: {
+ title: string;
+ examples: BadgeExamples;
+ }
+}
-function extractExampleList (badgeList): Examples {
- const examples = []
+
+const examples = extractExampleList(badgeList)
+
+function extractExampleList (badgeList: BadgeList): BadgeExamples {
+ let examples = {}
Object.entries(badgeList).forEach((x) => {
- console.log(x)
- // Object.entries(meta?.examples)
+ examples = { ...examples, ...x[1].examples }
+ })
+
+ // Also apply legacy examples
+ badgeListLegacy.live.forEach((x) => {
+ examples = { ...examples, ...x.examples }
})
return examples
@@ -24,13 +40,11 @@ interface BuilderHelperProps {
}
export default function BuilderHelper ({ badgeURL, onSelect }: BuilderHelperProps) {
- console.log(2333)
if (badgeURL.length < 2) {
return
}
- const examples = extractExampleList(badgeList)
- const matched = examples.filter(eg => eg[0].includes(badgeURL))
+ const matched = Object.entries(examples).filter(eg => eg[0].includes(badgeURL))
const hints = matched.length === 1 && matched[0][0] === '/' + badgeURL ? null : (
diff --git a/components/builder-hints.tsx b/components/builder-hints.tsx
index 0bd926f..cec278a 100644
--- a/components/builder-hints.tsx
+++ b/components/builder-hints.tsx
@@ -27,7 +27,7 @@ export default function BuilderHints ({ focus, badgeURL }) {
overflow: visible;
width: 100%;
left: -147px;
- height: 200px;
+ /* height: 200px; */
transition: all 200ms cubic-bezier(0.215, 0.61, 0.355, 1);
}
.hint a {
diff --git a/libs/badge-list.ts b/libs/badge-list.ts
index 7fc822e..b2a91d3 100644
--- a/libs/badge-list.ts
+++ b/libs/badge-list.ts
@@ -7,82 +7,80 @@ const rel = (...args) => path.resolve(__dirname, ...args)
export const liveBadgeList = [
// // source control
// 'github',
- // 'gitlab',
- // // release registries
- // 'npm',
- // 'david',
- // 'packagephobia',
- // 'bundlephobia',
- // 'crates',
- // 'docker',
- // 'homebrew',
- // 'chrome-web-store',
- // 'amo',
- // 'pypi',
- // 'nuget',
- // 'packagist',
- // 'rubygems',
- // 'apm',
- // 'hackage',
- // 'vs-marketplace',
- // 'melpa',
- // 'maven',
- // 'cocoapods',
- // 'haxelib',
- // 'opam',
- // 'cpan',
- // 'cran',
- // 'ctan',
- // 'dub',
- // 'elm-package',
- // 'scoop',
- // 'winget',
- // 'f-droid',
- // 'pub',
- // 'shards',
- // 'wapm',
- // 'open-vsx',
- // 'snapcraft',
- // // CI
- // 'travis',
- // 'circleci',
- // 'appveyor',
- // 'codecov',
- // 'codacy',
- // 'coveralls',
- // 'codeclimate',
- // 'azure-pipelines',
- // // quality & metrics
- // 'snyk',
- // 'lgtm',
- // 'deepscan',
- // 'uptime-robot',
- // 'xo',
- // 'badgesize',
- // 'jsdelivr',
- // // social
- // 'devrant',
- // 'peertube',
- // 'reddit',
- // // chat
- // 'discord',
- // 'gitter',
- // 'matrix',
- // // utilities
- // 'opencollective',
- // 'keybase',
- // 'twitter',
- // 'mastodon',
- // 'tidelift',
- // 'jenkins',
- // 'liberapay',
- // 'runkit',
- // 'https',
+ 'gitlab',
+ // release registries
+ 'npm',
+ 'david',
+ 'packagephobia',
+ 'bundlephobia',
+ 'crates',
+ 'docker',
+ 'homebrew',
+ 'chrome-web-store',
+ 'amo',
+ 'pypi',
+ 'nuget',
+ 'packagist',
+ 'rubygems',
+ 'apm',
+ 'hackage',
+ 'vs-marketplace',
+ 'melpa',
+ 'maven',
+ 'cocoapods',
+ 'haxelib',
+ 'opam',
+ 'cpan',
+ 'cran',
+ 'ctan',
+ 'dub',
+ 'elm-package',
+ 'scoop',
+ 'f-droid',
+ 'pub',
+ 'shards',
+ 'wapm',
+ 'open-vsx',
+ 'snapcraft',
+ // CI
+ 'travis',
+ 'circleci',
+ 'appveyor',
+ 'codecov',
+ 'codacy',
+ 'coveralls',
+ 'codeclimate',
+ 'azure-pipelines',
+ // quality & metrics
+ 'snyk',
+ 'lgtm',
+ 'deepscan',
+ 'uptime-robot',
+ 'badgesize',
+ 'jsdelivr',
+ // social
+ 'devrant',
+ 'peertube',
+ 'reddit',
+ // chat
+ 'discord',
+ 'gitter',
+ 'matrix',
+ // utilities
+ 'opencollective',
+ 'keybase',
+ 'twitter',
+ 'mastodon',
+ 'tidelift',
+ 'jenkins',
+ 'liberapay',
+ 'runkit',
+ 'https',
]
export async function loadBadgeMeta () {
const liveBadgeExamples = await Promise.all(liveBadgeList.map(async id => {
- const mod = await import(rel('../api', id))
+ const mod = await import(rel('../api-', id))
const { title, examples, handlers } = mod.default.meta
return {
diff --git a/tools/gen-examples.ts b/tools/gen-examples.ts
index 8b2796f..3a76d90 100644
--- a/tools/gen-examples.ts
+++ b/tools/gen-examples.ts
@@ -6,11 +6,13 @@ import BadgeList2 from '../libs/badge-list2'
const rel = (...args) => path.resolve(__dirname, ...args)
;(async function main () {
+ // old list
const badgeMeta = await loadBadgeMeta()
await fse.outputJson(rel('../public/.meta/badges.json'), badgeMeta, {
spaces: 2
})
+ // new list
await fse.outputJson(rel('../public/.meta/badge-list.json'), BadgeList2, {
spaces: 2
})