@reallukemanning/folio 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/copy-components.js +31 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/core/copy-components.js.html +178 -0
- package/coverage/core/eslint.config.js.html +184 -0
- package/coverage/core/index.html +146 -0
- package/coverage/core/src/__tests__/benchmarks/ProjectCard.bench.tsx.html +364 -0
- package/coverage/core/src/__tests__/benchmarks/ProjectView.bench.tsx.html +484 -0
- package/coverage/core/src/__tests__/benchmarks/github.bench.ts.html +244 -0
- package/coverage/core/src/__tests__/benchmarks/index.html +191 -0
- package/coverage/core/src/__tests__/benchmarks/npm.bench.ts.html +271 -0
- package/coverage/core/src/__tests__/benchmarks/product-hunt.bench.ts.html +259 -0
- package/coverage/core/src/__tests__/benchmarks/utilities.bench.ts.html +478 -0
- package/coverage/core/src/components/FeaturedProject.test.tsx.html +697 -0
- package/coverage/core/src/components/FeaturedProject.tsx.html +163 -0
- package/coverage/core/src/components/ProjectCard/ProjectCard.test.tsx.html +928 -0
- package/coverage/core/src/components/ProjectCard/ProjectCard.tsx.html +379 -0
- package/coverage/core/src/components/ProjectCard/index.html +146 -0
- package/coverage/core/src/components/ProjectCard/index.ts.html +88 -0
- package/coverage/core/src/components/ProjectGrid/ProjectGrid.test.tsx.html +292 -0
- package/coverage/core/src/components/ProjectGrid/ProjectGrid.tsx.html +103 -0
- package/coverage/core/src/components/ProjectGrid/index.html +146 -0
- package/coverage/core/src/components/ProjectGrid/index.ts.html +88 -0
- package/coverage/core/src/components/ProjectList/ProjectList.test.tsx.html +292 -0
- package/coverage/core/src/components/ProjectList/ProjectList.tsx.html +103 -0
- package/coverage/core/src/components/ProjectList/index.html +146 -0
- package/coverage/core/src/components/ProjectList/index.ts.html +88 -0
- package/coverage/core/src/components/ProjectView/ProjectView.test.tsx.html +1108 -0
- package/coverage/core/src/components/ProjectView/ProjectView.tsx.html +589 -0
- package/coverage/core/src/components/ProjectView/index.html +146 -0
- package/coverage/core/src/components/ProjectView/index.ts.html +88 -0
- package/coverage/core/src/components/index.html +146 -0
- package/coverage/core/src/components/index.ts.html +97 -0
- package/coverage/core/src/index.html +116 -0
- package/coverage/core/src/index.ts.html +94 -0
- package/coverage/core/src/lib/__tests__/defineProjects.test.ts.html +421 -0
- package/coverage/core/src/lib/__tests__/filterByFeatured.test.ts.html +523 -0
- package/coverage/core/src/lib/__tests__/filterByStatus.test.ts.html +664 -0
- package/coverage/core/src/lib/__tests__/filterByType.test.ts.html +631 -0
- package/coverage/core/src/lib/__tests__/github.test.ts.html +1783 -0
- package/coverage/core/src/lib/__tests__/hybrid-config.test.ts.html +1345 -0
- package/coverage/core/src/lib/__tests__/index.html +311 -0
- package/coverage/core/src/lib/__tests__/normalise.test.ts.html +1585 -0
- package/coverage/core/src/lib/__tests__/npm-config.test.ts.html +385 -0
- package/coverage/core/src/lib/__tests__/npm.test.ts.html +1135 -0
- package/coverage/core/src/lib/__tests__/product-hunt-config.test.ts.html +397 -0
- package/coverage/core/src/lib/__tests__/product-hunt.test.ts.html +505 -0
- package/coverage/core/src/lib/__tests__/sortByDate.test.ts.html +751 -0
- package/coverage/core/src/lib/__tests__/sortByName.test.ts.html +832 -0
- package/coverage/core/src/lib/__tests__/sortByStars.test.ts.html +703 -0
- package/coverage/core/src/lib/defineProjects.ts.html +100 -0
- package/coverage/core/src/lib/filterByFeatured.ts.html +133 -0
- package/coverage/core/src/lib/filterByStatus.ts.html +145 -0
- package/coverage/core/src/lib/filterByType.ts.html +133 -0
- package/coverage/core/src/lib/github.ts.html +517 -0
- package/coverage/core/src/lib/index.html +281 -0
- package/coverage/core/src/lib/index.ts.html +130 -0
- package/coverage/core/src/lib/normalise.ts.html +868 -0
- package/coverage/core/src/lib/npm.ts.html +199 -0
- package/coverage/core/src/lib/product-hunt.ts.html +256 -0
- package/coverage/core/src/lib/sortByDate.ts.html +175 -0
- package/coverage/core/src/lib/sortByName.ts.html +172 -0
- package/coverage/core/src/lib/sortByStars.ts.html +172 -0
- package/coverage/core/src/types/index.html +116 -0
- package/coverage/core/src/types/index.ts.html +517 -0
- package/coverage/core/vitest.config.ts.html +178 -0
- package/coverage/coverage-final.json +53 -0
- package/coverage/coverage-summary.json +54 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +266 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +210 -0
- package/dist/cli-components/FeaturedProject/FeaturedProject.d.ts +6 -0
- package/dist/cli-components/FeaturedProject/FeaturedProject.d.ts.map +1 -0
- package/dist/cli-components/FeaturedProject/FeaturedProject.js +9 -0
- package/dist/cli-components/FeaturedProject/FeaturedProject.js.map +1 -0
- package/dist/cli-components/FeaturedProject/FeaturedProject.tsx +54 -0
- package/dist/cli-components/FeaturedProject/index.d.ts +3 -0
- package/dist/cli-components/FeaturedProject/index.d.ts.map +1 -0
- package/dist/cli-components/FeaturedProject/index.js +2 -0
- package/dist/cli-components/FeaturedProject/index.js.map +1 -0
- package/dist/cli-components/FeaturedProject/index.ts +2 -0
- package/dist/cli-components/ProjectCard/ProjectCard.d.ts +26 -0
- package/dist/cli-components/ProjectCard/ProjectCard.d.ts.map +1 -0
- package/dist/cli-components/ProjectCard/ProjectCard.js +33 -0
- package/dist/cli-components/ProjectCard/ProjectCard.js.map +1 -0
- package/dist/cli-components/ProjectCard/ProjectCard.tsx +90 -0
- package/dist/cli-components/ProjectCard/index.d.ts +3 -0
- package/dist/cli-components/ProjectCard/index.d.ts.map +1 -0
- package/dist/cli-components/ProjectCard/index.js +2 -0
- package/dist/cli-components/ProjectCard/index.js.map +1 -0
- package/dist/cli-components/ProjectCard/index.ts +2 -0
- package/dist/cli-components/ProjectGrid/ProjectGrid.d.ts +5 -0
- package/dist/cli-components/ProjectGrid/ProjectGrid.d.ts.map +1 -0
- package/dist/cli-components/ProjectGrid/ProjectGrid.js +8 -0
- package/dist/cli-components/ProjectGrid/ProjectGrid.js.map +1 -0
- package/dist/cli-components/ProjectGrid/ProjectGrid.tsx +6 -0
- package/dist/cli-components/ProjectGrid/index.d.ts +3 -0
- package/dist/cli-components/ProjectGrid/index.d.ts.map +1 -0
- package/dist/cli-components/ProjectGrid/index.js +2 -0
- package/dist/cli-components/ProjectGrid/index.js.map +1 -0
- package/dist/cli-components/ProjectGrid/index.ts +2 -0
- package/dist/cli-components/ProjectList/ProjectList.d.ts +5 -0
- package/dist/cli-components/ProjectList/ProjectList.d.ts.map +1 -0
- package/dist/cli-components/ProjectList/ProjectList.js +8 -0
- package/dist/cli-components/ProjectList/ProjectList.js.map +1 -0
- package/dist/cli-components/ProjectList/ProjectList.tsx +6 -0
- package/dist/cli-components/ProjectList/index.d.ts +3 -0
- package/dist/cli-components/ProjectList/index.d.ts.map +1 -0
- package/dist/cli-components/ProjectList/index.js +2 -0
- package/dist/cli-components/ProjectList/index.js.map +1 -0
- package/dist/cli-components/ProjectList/index.ts +2 -0
- package/dist/cli-components/ProjectView/ProjectView.d.ts +17 -0
- package/dist/cli-components/ProjectView/ProjectView.d.ts.map +1 -0
- package/dist/cli-components/ProjectView/ProjectView.js +39 -0
- package/dist/cli-components/ProjectView/ProjectView.js.map +1 -0
- package/dist/cli-components/ProjectView/ProjectView.tsx +117 -0
- package/dist/cli-components/ProjectView/index.d.ts +3 -0
- package/dist/cli-components/ProjectView/index.d.ts.map +1 -0
- package/dist/cli-components/ProjectView/index.js +2 -0
- package/dist/cli-components/ProjectView/index.js.map +1 -0
- package/dist/cli-components/ProjectView/index.ts +2 -0
- package/dist/cli-components/types.d.ts +52 -0
- package/dist/cli-components/types.d.ts.map +1 -0
- package/dist/cli-components/types.js +2 -0
- package/dist/cli-components/types.js.map +1 -0
- package/dist/cli-components/types.ts +58 -0
- package/dist/cli-types.d.ts +52 -0
- package/dist/cli-types.d.ts.map +1 -0
- package/dist/cli-types.js +2 -0
- package/dist/cli-types.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +21 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/add.d.ts +2 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +166 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/init.d.ts +6 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +231 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/components/FeaturedProject.d.ts +7 -0
- package/dist/components/FeaturedProject.d.ts.map +1 -0
- package/dist/components/FeaturedProject.js +10 -0
- package/dist/components/FeaturedProject.js.map +1 -0
- package/dist/components/FeaturedProject.test.tsx +204 -0
- package/dist/components/FeaturedProject.tsx +26 -0
- package/dist/components/ProjectCard/ProjectCard.d.ts +26 -0
- package/dist/components/ProjectCard/ProjectCard.d.ts.map +1 -0
- package/dist/components/ProjectCard/ProjectCard.js +39 -0
- package/dist/components/ProjectCard/ProjectCard.js.map +1 -0
- package/dist/components/ProjectCard/ProjectCard.test.tsx +281 -0
- package/dist/components/ProjectCard/ProjectCard.tsx +98 -0
- package/dist/components/ProjectCard/index.d.ts +2 -0
- package/dist/components/ProjectCard/index.d.ts.map +1 -0
- package/dist/components/ProjectCard/index.js +2 -0
- package/dist/components/ProjectCard/index.js.map +1 -0
- package/dist/components/ProjectCard/index.ts +1 -0
- package/dist/components/ProjectGrid/ProjectGrid.d.ts +5 -0
- package/dist/components/ProjectGrid/ProjectGrid.d.ts.map +1 -0
- package/dist/components/ProjectGrid/ProjectGrid.js +8 -0
- package/dist/components/ProjectGrid/ProjectGrid.js.map +1 -0
- package/dist/components/ProjectGrid/ProjectGrid.test.tsx +69 -0
- package/dist/components/ProjectGrid/ProjectGrid.tsx +6 -0
- package/dist/components/ProjectGrid/index.d.ts +2 -0
- package/dist/components/ProjectGrid/index.d.ts.map +1 -0
- package/dist/components/ProjectGrid/index.js +2 -0
- package/dist/components/ProjectGrid/index.js.map +1 -0
- package/dist/components/ProjectGrid/index.ts +1 -0
- package/dist/components/ProjectList/ProjectList.d.ts +5 -0
- package/dist/components/ProjectList/ProjectList.d.ts.map +1 -0
- package/dist/components/ProjectList/ProjectList.js +8 -0
- package/dist/components/ProjectList/ProjectList.js.map +1 -0
- package/dist/components/ProjectList/ProjectList.test.tsx +69 -0
- package/dist/components/ProjectList/ProjectList.tsx +6 -0
- package/dist/components/ProjectList/index.d.ts +2 -0
- package/dist/components/ProjectList/index.d.ts.map +1 -0
- package/dist/components/ProjectList/index.js +2 -0
- package/dist/components/ProjectList/index.js.map +1 -0
- package/dist/components/ProjectList/index.ts +1 -0
- package/dist/components/ProjectView/ProjectView.d.ts +20 -0
- package/dist/components/ProjectView/ProjectView.d.ts.map +1 -0
- package/dist/components/ProjectView/ProjectView.js +64 -0
- package/dist/components/ProjectView/ProjectView.js.map +1 -0
- package/dist/components/ProjectView/ProjectView.test.tsx +341 -0
- package/dist/components/ProjectView/ProjectView.tsx +168 -0
- package/dist/components/ProjectView/index.d.ts +2 -0
- package/dist/components/ProjectView/index.d.ts.map +1 -0
- package/dist/components/ProjectView/index.js +2 -0
- package/dist/components/ProjectView/index.js.map +1 -0
- package/dist/components/ProjectView/index.ts +1 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +5 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.ts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/defineProjects.d.ts +3 -0
- package/dist/lib/defineProjects.d.ts.map +1 -0
- package/dist/lib/defineProjects.js +4 -0
- package/dist/lib/defineProjects.js.map +1 -0
- package/dist/lib/filterByFeatured.d.ts +3 -0
- package/dist/lib/filterByFeatured.d.ts.map +1 -0
- package/dist/lib/filterByFeatured.js +10 -0
- package/dist/lib/filterByFeatured.js.map +1 -0
- package/dist/lib/filterByStatus.d.ts +3 -0
- package/dist/lib/filterByStatus.d.ts.map +1 -0
- package/dist/lib/filterByStatus.js +13 -0
- package/dist/lib/filterByStatus.js.map +1 -0
- package/dist/lib/filterByType.d.ts +3 -0
- package/dist/lib/filterByType.d.ts.map +1 -0
- package/dist/lib/filterByType.js +10 -0
- package/dist/lib/filterByType.js.map +1 -0
- package/dist/lib/github.d.ts +24 -0
- package/dist/lib/github.d.ts.map +1 -0
- package/dist/lib/github.js +107 -0
- package/dist/lib/github.js.map +1 -0
- package/dist/lib/index.d.ts +16 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +12 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/normalise.d.ts +4 -0
- package/dist/lib/normalise.d.ts.map +1 -0
- package/dist/lib/normalise.js +221 -0
- package/dist/lib/normalise.js.map +1 -0
- package/dist/lib/npm.d.ts +7 -0
- package/dist/lib/npm.d.ts.map +1 -0
- package/dist/lib/npm.js +28 -0
- package/dist/lib/npm.js.map +1 -0
- package/dist/lib/product-hunt.d.ts +12 -0
- package/dist/lib/product-hunt.d.ts.map +1 -0
- package/dist/lib/product-hunt.js +40 -0
- package/dist/lib/product-hunt.js.map +1 -0
- package/dist/lib/sortByDate.d.ts +4 -0
- package/dist/lib/sortByDate.d.ts.map +1 -0
- package/dist/lib/sortByDate.js +21 -0
- package/dist/lib/sortByDate.js.map +1 -0
- package/dist/lib/sortByName.d.ts +4 -0
- package/dist/lib/sortByName.d.ts.map +1 -0
- package/dist/lib/sortByName.js +21 -0
- package/dist/lib/sortByName.js.map +1 -0
- package/dist/lib/sortByStars.d.ts +4 -0
- package/dist/lib/sortByStars.d.ts.map +1 -0
- package/dist/lib/sortByStars.js +21 -0
- package/dist/lib/sortByStars.js.map +1 -0
- package/dist/test-setup.d.ts +2 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/dist/test-setup.js +2 -0
- package/dist/test-setup.js.map +1 -0
- package/dist/types/index.d.ts +121 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/eslint.config.js +33 -0
- package/package.json +47 -0
- package/playwright-report/index.html +85 -0
- package/src/__tests__/benchmarks/ProjectCard.bench.tsx +93 -0
- package/src/__tests__/benchmarks/ProjectView.bench.tsx +133 -0
- package/src/__tests__/benchmarks/github.bench.ts +53 -0
- package/src/__tests__/benchmarks/npm.bench.ts +62 -0
- package/src/__tests__/benchmarks/product-hunt.bench.ts +58 -0
- package/src/__tests__/benchmarks/utilities.bench.ts +131 -0
- package/src/cli-components/FeaturedProject/FeaturedProject.tsx +54 -0
- package/src/cli-components/FeaturedProject/index.ts +2 -0
- package/src/cli-components/ProjectCard/ProjectCard.tsx +90 -0
- package/src/cli-components/ProjectCard/index.ts +2 -0
- package/src/cli-components/ProjectGrid/ProjectGrid.tsx +6 -0
- package/src/cli-components/ProjectGrid/index.ts +2 -0
- package/src/cli-components/ProjectList/ProjectList.tsx +6 -0
- package/src/cli-components/ProjectList/index.ts +2 -0
- package/src/cli-components/ProjectView/ProjectView.tsx +117 -0
- package/src/cli-components/ProjectView/index.ts +2 -0
- package/src/cli-components/types.ts +58 -0
- package/src/cli-types.ts +58 -0
- package/src/cli.ts +26 -0
- package/src/commands/add.ts +191 -0
- package/src/commands/init.ts +260 -0
- package/src/components/FeaturedProject.test.tsx +204 -0
- package/src/components/FeaturedProject.tsx +26 -0
- package/src/components/ProjectCard/ProjectCard.test.tsx +281 -0
- package/src/components/ProjectCard/ProjectCard.tsx +98 -0
- package/src/components/ProjectCard/index.ts +1 -0
- package/src/components/ProjectGrid/ProjectGrid.test.tsx +69 -0
- package/src/components/ProjectGrid/ProjectGrid.tsx +6 -0
- package/src/components/ProjectGrid/index.ts +1 -0
- package/src/components/ProjectList/ProjectList.test.tsx +69 -0
- package/src/components/ProjectList/ProjectList.tsx +6 -0
- package/src/components/ProjectList/index.ts +1 -0
- package/src/components/ProjectView/ProjectView.test.tsx +341 -0
- package/src/components/ProjectView/ProjectView.tsx +168 -0
- package/src/components/ProjectView/index.ts +1 -0
- package/src/components/index.ts +4 -0
- package/src/index.ts +3 -0
- package/src/lib/__tests__/defineProjects.test.ts +112 -0
- package/src/lib/__tests__/filterByFeatured.test.ts +146 -0
- package/src/lib/__tests__/filterByStatus.test.ts +193 -0
- package/src/lib/__tests__/filterByType.test.ts +182 -0
- package/src/lib/__tests__/github.test.ts +566 -0
- package/src/lib/__tests__/hybrid-config.test.ts +420 -0
- package/src/lib/__tests__/normalise.test.ts +500 -0
- package/src/lib/__tests__/npm-config.test.ts +100 -0
- package/src/lib/__tests__/npm.test.ts +350 -0
- package/src/lib/__tests__/product-hunt-config.test.ts +104 -0
- package/src/lib/__tests__/product-hunt.test.ts +140 -0
- package/src/lib/__tests__/sortByDate.test.ts +222 -0
- package/src/lib/__tests__/sortByName.test.ts +249 -0
- package/src/lib/__tests__/sortByStars.test.ts +206 -0
- package/src/lib/defineProjects.ts +5 -0
- package/src/lib/filterByFeatured.ts +16 -0
- package/src/lib/filterByStatus.ts +20 -0
- package/src/lib/filterByType.ts +16 -0
- package/src/lib/github.ts +144 -0
- package/src/lib/index.ts +15 -0
- package/src/lib/normalise.ts +261 -0
- package/src/lib/npm.ts +38 -0
- package/src/lib/product-hunt.ts +57 -0
- package/src/lib/sortByDate.ts +30 -0
- package/src/lib/sortByName.ts +29 -0
- package/src/lib/sortByStars.ts +29 -0
- package/src/test-setup.ts +1 -0
- package/src/types/index.ts +144 -0
- package/test-results/.last-run.json +62 -0
- package/tsconfig.json +29 -0
- package/vitest.config.ts +31 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
function isValidSectionName(name) {
|
|
3
|
+
return ['description', 'background', 'why', 'stack', 'struggles', 'timeline', 'posts'].includes(name);
|
|
4
|
+
}
|
|
5
|
+
function ProjectView({ project, onBack, children }) {
|
|
6
|
+
return (_jsxs("div", { "data-folio-view": true, children: [onBack && _jsx("button", { onClick: onBack, children: "Back" }), _jsx("h2", { children: project.name }), children] }));
|
|
7
|
+
}
|
|
8
|
+
ProjectView.Section = function ProjectViewSection({ project, name }) {
|
|
9
|
+
if (!isValidSectionName(name))
|
|
10
|
+
return null;
|
|
11
|
+
const sectionData = project[name];
|
|
12
|
+
if (!sectionData)
|
|
13
|
+
return null;
|
|
14
|
+
return (_jsxs("div", { "data-folio-view-section": true, "data-folio-view-section-name": name, children: [typeof sectionData === 'string' && _jsx(_Fragment, { children: sectionData }), Array.isArray(sectionData) &&
|
|
15
|
+
sectionData.map((item, index) => {
|
|
16
|
+
if (typeof item === 'string') {
|
|
17
|
+
return _jsx("span", { "data-folio-tag": true, children: item }, index);
|
|
18
|
+
}
|
|
19
|
+
if ('type' in item && 'text' in item) {
|
|
20
|
+
const struggle = item;
|
|
21
|
+
return (_jsx("div", { "data-folio-struggle": true, "data-folio-struggle-type": struggle.type, children: struggle.text }, index));
|
|
22
|
+
}
|
|
23
|
+
if ('date' in item && ('note' in item || 'title' in item)) {
|
|
24
|
+
if ('note' in item) {
|
|
25
|
+
const timeline = item;
|
|
26
|
+
return (_jsxs("div", { children: [_jsx("span", { "data-folio-timeline-date": true, children: timeline.date }), _jsx("span", { "data-folio-timeline-note": true, children: timeline.note })] }, index));
|
|
27
|
+
}
|
|
28
|
+
if ('title' in item) {
|
|
29
|
+
const post = item;
|
|
30
|
+
return (_jsxs("div", { children: [_jsx("span", { "data-folio-post-title": true, children: post.title }), _jsx("span", { "data-folio-post-date": true, children: post.date }), post.url && (_jsx("a", { href: post.url, "data-folio-post-link": true, children: "Link" }))] }, index));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
})] }));
|
|
35
|
+
};
|
|
36
|
+
ProjectView.Links = function ProjectViewLinks({ project }) {
|
|
37
|
+
const links = project.links;
|
|
38
|
+
if (!links.github &&
|
|
39
|
+
!links.live &&
|
|
40
|
+
!links.npm &&
|
|
41
|
+
!links.appStore &&
|
|
42
|
+
!links.playStore &&
|
|
43
|
+
!links.productHunt) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return (_jsxs("div", { "data-folio-view-links": true, children: [links.github && (_jsx("a", { href: links.github, "data-folio-link": true, "data-folio-link-type": "github", children: "GitHub" })), links.live && (_jsx("a", { href: links.live, "data-folio-link": true, "data-folio-link-type": "live", children: "Live" })), links.npm && (_jsx("a", { href: links.npm, "data-folio-link": true, "data-folio-link-type": "npm", children: "npm" })), links.appStore && (_jsx("a", { href: links.appStore, "data-folio-link": true, "data-folio-link-type": "app-store", children: "App Store" })), links.playStore && (_jsx("a", { href: links.playStore, "data-folio-link": true, "data-folio-link-type": "play-store", children: "Play Store" })), links.productHunt && (_jsx("a", { href: links.productHunt, "data-folio-link": true, "data-folio-link-type": "product-hunt", children: "Product Hunt" }))] }));
|
|
47
|
+
};
|
|
48
|
+
ProjectView.Stats = function ProjectViewStats({ project }) {
|
|
49
|
+
if (!project.stats) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const hasStats = project.stats.stars ||
|
|
53
|
+
project.stats.forks ||
|
|
54
|
+
project.stats.downloads ||
|
|
55
|
+
project.stats.version ||
|
|
56
|
+
project.stats.upvotes ||
|
|
57
|
+
project.stats.comments;
|
|
58
|
+
if (!hasStats) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
return (_jsxs("div", { "data-folio-view-stats": true, children: [project.stats.stars && _jsxs("span", { "data-folio-stat": "stars", children: [project.stats.stars, " stars"] }), project.stats.forks && _jsxs("span", { "data-folio-stat": "forks", children: [project.stats.forks, " forks"] }), project.stats.downloads && (_jsxs("span", { "data-folio-stat": "downloads", children: [project.stats.downloads, " downloads"] })), project.stats.version && _jsx("span", { "data-folio-stat": "version", children: project.stats.version }), project.stats.upvotes && _jsxs("span", { "data-folio-stat": "upvotes", children: [project.stats.upvotes, " upvotes"] }), project.stats.comments && _jsxs("span", { "data-folio-stat": "comments", children: [project.stats.comments, " comments"] })] }));
|
|
62
|
+
};
|
|
63
|
+
export { ProjectView };
|
|
64
|
+
//# sourceMappingURL=ProjectView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectView.js","sourceRoot":"","sources":["../../../src/components/ProjectView/ProjectView.tsx"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest'
|
|
2
|
+
import { render, screen, cleanup } from '@testing-library/react'
|
|
3
|
+
import { ProjectView } from './ProjectView'
|
|
4
|
+
import type { FolioProject } from '../../types'
|
|
5
|
+
|
|
6
|
+
afterEach(() => {
|
|
7
|
+
cleanup()
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
const createProject = (overrides: Partial<FolioProject> = {}): FolioProject => ({
|
|
11
|
+
id: 'test-project',
|
|
12
|
+
type: 'github',
|
|
13
|
+
status: 'active',
|
|
14
|
+
featured: false,
|
|
15
|
+
name: 'Test Project',
|
|
16
|
+
tagline: 'A test project',
|
|
17
|
+
description: 'This is a test project description',
|
|
18
|
+
background: 'This is the background story of the project.',
|
|
19
|
+
why: 'Why I built this project.',
|
|
20
|
+
image: null,
|
|
21
|
+
struggles: [
|
|
22
|
+
{ type: 'warn', text: 'First challenge faced' },
|
|
23
|
+
{ type: 'error', text: 'Critical issue encountered' },
|
|
24
|
+
],
|
|
25
|
+
timeline: [
|
|
26
|
+
{ date: '2024-01-01', note: 'Project started' },
|
|
27
|
+
{ date: '2024-06-01', note: 'First release' },
|
|
28
|
+
],
|
|
29
|
+
posts: [
|
|
30
|
+
{ title: 'Announcement Post', date: '2024-02-01', url: 'https://blog.com/post1' },
|
|
31
|
+
{ title: 'Update Post', date: '2024-07-01' },
|
|
32
|
+
],
|
|
33
|
+
stack: ['React', 'TypeScript', 'Node.js'],
|
|
34
|
+
links: {
|
|
35
|
+
github: 'https://github.com/test/project',
|
|
36
|
+
live: 'https://test-project.com',
|
|
37
|
+
},
|
|
38
|
+
stats: {
|
|
39
|
+
stars: 100,
|
|
40
|
+
forks: 20,
|
|
41
|
+
},
|
|
42
|
+
language: 'TypeScript',
|
|
43
|
+
languageColor: '#3178c6',
|
|
44
|
+
createdAt: '2024-01-01',
|
|
45
|
+
updatedAt: '2024-06-01',
|
|
46
|
+
...overrides,
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
describe('ProjectView', () => {
|
|
50
|
+
it('renders with project sections displaying correct content', () => {
|
|
51
|
+
const project = createProject()
|
|
52
|
+
|
|
53
|
+
const { container } = render(
|
|
54
|
+
<ProjectView project={project}>
|
|
55
|
+
<ProjectView.Section project={project} name="background" />
|
|
56
|
+
<ProjectView.Section project={project} name="why" />
|
|
57
|
+
</ProjectView>
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
expect(screen.getByRole('heading', { level: 2 })).toHaveTextContent('Test Project')
|
|
61
|
+
expect(container.querySelector('[data-folio-view-section-name="background"]')).toHaveTextContent(/This is the background story/)
|
|
62
|
+
expect(screen.getByText('Why I built this project.')).toBeInTheDocument()
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('renders back button when onBack is provided', () => {
|
|
66
|
+
const project = createProject()
|
|
67
|
+
const onBack = () => {}
|
|
68
|
+
|
|
69
|
+
render(
|
|
70
|
+
<ProjectView project={project} onBack={onBack}>
|
|
71
|
+
<span>Content</span>
|
|
72
|
+
</ProjectView>
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
expect(screen.getByRole('button', { name: 'Back' })).toBeInTheDocument()
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('does not render back button when onBack is not provided', () => {
|
|
79
|
+
const project = createProject()
|
|
80
|
+
|
|
81
|
+
const { container } = render(
|
|
82
|
+
<ProjectView project={project}>
|
|
83
|
+
<span>Content</span>
|
|
84
|
+
</ProjectView>
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
expect(container.querySelector('button')).not.toBeInTheDocument()
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
describe('ProjectView sections conditional rendering', () => {
|
|
92
|
+
it('does not render section when data is null', () => {
|
|
93
|
+
const project = createProject({ background: null })
|
|
94
|
+
|
|
95
|
+
const { container } = render(<ProjectView.Section project={project} name="background" />)
|
|
96
|
+
|
|
97
|
+
expect(container.querySelector('[data-folio-view-section]')).not.toBeInTheDocument()
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
it('does not render section when data is empty string', () => {
|
|
101
|
+
const project = createProject({ background: '' })
|
|
102
|
+
|
|
103
|
+
const { container } = render(<ProjectView.Section project={project} name="background" />)
|
|
104
|
+
|
|
105
|
+
expect(container.querySelector('[data-folio-view-section]')).not.toBeInTheDocument()
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it('renders empty section wrapper when data is empty array', () => {
|
|
109
|
+
const project = createProject({ struggles: [] })
|
|
110
|
+
|
|
111
|
+
const { container } = render(<ProjectView.Section project={project} name="struggles" />)
|
|
112
|
+
|
|
113
|
+
expect(container.querySelector('[data-folio-view-section]')).toBeInTheDocument()
|
|
114
|
+
expect(container.querySelector('[data-folio-struggle]')).not.toBeInTheDocument()
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('renders background section when present', () => {
|
|
118
|
+
const project = createProject({ background: 'Background info' })
|
|
119
|
+
|
|
120
|
+
const { container } = render(<ProjectView.Section project={project} name="background" />)
|
|
121
|
+
|
|
122
|
+
expect(container.querySelector('[data-folio-view-section]')).toBeInTheDocument()
|
|
123
|
+
expect(screen.getByText('Background info')).toBeInTheDocument()
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
it('renders why section when present', () => {
|
|
127
|
+
const project = createProject({ why: 'Why this matters' })
|
|
128
|
+
|
|
129
|
+
const { container } = render(<ProjectView.Section project={project} name="why" />)
|
|
130
|
+
|
|
131
|
+
expect(container.querySelector('[data-folio-view-section]')).toBeInTheDocument()
|
|
132
|
+
expect(screen.getByText('Why this matters')).toBeInTheDocument()
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
it('renders struggles with correct attributes', () => {
|
|
136
|
+
const project = createProject()
|
|
137
|
+
|
|
138
|
+
const { container } = render(<ProjectView.Section project={project} name="struggles" />)
|
|
139
|
+
|
|
140
|
+
expect(container.querySelectorAll('[data-folio-struggle]')).toHaveLength(2)
|
|
141
|
+
|
|
142
|
+
const warnStruggle = container.querySelector('[data-folio-struggle-type="warn"]')
|
|
143
|
+
expect(warnStruggle).toBeInTheDocument()
|
|
144
|
+
expect(warnStruggle).toHaveTextContent('First challenge faced')
|
|
145
|
+
|
|
146
|
+
const errorStruggle = container.querySelector('[data-folio-struggle-type="error"]')
|
|
147
|
+
expect(errorStruggle).toBeInTheDocument()
|
|
148
|
+
expect(errorStruggle).toHaveTextContent('Critical issue encountered')
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
it('renders timeline with correct attributes', () => {
|
|
152
|
+
const project = createProject()
|
|
153
|
+
|
|
154
|
+
const { container } = render(<ProjectView.Section project={project} name="timeline" />)
|
|
155
|
+
|
|
156
|
+
expect(container.querySelectorAll('[data-folio-timeline-date]')).toHaveLength(2)
|
|
157
|
+
expect(container.querySelectorAll('[data-folio-timeline-note]')).toHaveLength(2)
|
|
158
|
+
expect(screen.getByText('2024-01-01')).toBeInTheDocument()
|
|
159
|
+
expect(screen.getByText('Project started')).toBeInTheDocument()
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
it('renders posts with correct attributes', () => {
|
|
163
|
+
const project = createProject()
|
|
164
|
+
|
|
165
|
+
const { container } = render(<ProjectView.Section project={project} name="posts" />)
|
|
166
|
+
|
|
167
|
+
expect(container.querySelectorAll('[data-folio-post-title]')).toHaveLength(2)
|
|
168
|
+
expect(container.querySelectorAll('[data-folio-post-date]')).toHaveLength(2)
|
|
169
|
+
|
|
170
|
+
expect(screen.getByText('Announcement Post')).toBeInTheDocument()
|
|
171
|
+
|
|
172
|
+
const postLink = container.querySelector('[data-folio-post-link]')
|
|
173
|
+
expect(postLink).toBeInTheDocument()
|
|
174
|
+
expect(postLink).toHaveAttribute('href', 'https://blog.com/post1')
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
it('renders posts without url without link', () => {
|
|
178
|
+
const project = createProject({
|
|
179
|
+
posts: [{ title: 'No URL Post', date: '2024-01-01' }]
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
const { container } = render(<ProjectView.Section project={project} name="posts" />)
|
|
183
|
+
|
|
184
|
+
expect(container.querySelector('[data-folio-post-link]')).not.toBeInTheDocument()
|
|
185
|
+
expect(screen.getByText('No URL Post')).toBeInTheDocument()
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
it('renders stack with tag attributes', () => {
|
|
189
|
+
const project = createProject()
|
|
190
|
+
|
|
191
|
+
const { container } = render(<ProjectView.Section project={project} name="stack" />)
|
|
192
|
+
|
|
193
|
+
expect(container.querySelectorAll('[data-folio-tag]')).toHaveLength(3)
|
|
194
|
+
})
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
describe('ProjectView Links', () => {
|
|
198
|
+
it('renders links when present', () => {
|
|
199
|
+
const project = createProject()
|
|
200
|
+
|
|
201
|
+
const { container } = render(<ProjectView.Links project={project} />)
|
|
202
|
+
|
|
203
|
+
expect(container.querySelector('[data-folio-view-links]')).toBeInTheDocument()
|
|
204
|
+
expect(container.querySelector('[data-folio-link-type="github"]')).toBeInTheDocument()
|
|
205
|
+
expect(container.querySelector('[data-folio-link-type="live"]')).toBeInTheDocument()
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
it('does not render when no links', () => {
|
|
209
|
+
const project = createProject({ links: {} })
|
|
210
|
+
|
|
211
|
+
const { container } = render(<ProjectView.Links project={project} />)
|
|
212
|
+
|
|
213
|
+
expect(container.querySelector('[data-folio-view-links]')).not.toBeInTheDocument()
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
it('renders app store link', () => {
|
|
217
|
+
const project = createProject({
|
|
218
|
+
links: { appStore: 'https://apps.apple.com/app/test' }
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
const { container } = render(<ProjectView.Links project={project} />)
|
|
222
|
+
|
|
223
|
+
const link = container.querySelector('[data-folio-link-type="app-store"]')
|
|
224
|
+
expect(link).toBeInTheDocument()
|
|
225
|
+
expect(link).toHaveAttribute('href', 'https://apps.apple.com/app/test')
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
it('renders play store link', () => {
|
|
229
|
+
const project = createProject({
|
|
230
|
+
links: { playStore: 'https://play.google.com/store/apps/test' }
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
const { container } = render(<ProjectView.Links project={project} />)
|
|
234
|
+
|
|
235
|
+
const link = container.querySelector('[data-folio-link-type="play-store"]')
|
|
236
|
+
expect(link).toBeInTheDocument()
|
|
237
|
+
expect(link).toHaveAttribute('href', 'https://play.google.com/store/apps/test')
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
it('renders product hunt link', () => {
|
|
241
|
+
const project = createProject({
|
|
242
|
+
links: { productHunt: 'https://producthunt.com/posts/test' }
|
|
243
|
+
})
|
|
244
|
+
|
|
245
|
+
const { container } = render(<ProjectView.Links project={project} />)
|
|
246
|
+
|
|
247
|
+
const link = container.querySelector('[data-folio-link-type="product-hunt"]')
|
|
248
|
+
expect(link).toBeInTheDocument()
|
|
249
|
+
expect(link).toHaveAttribute('href', 'https://producthunt.com/posts/test')
|
|
250
|
+
})
|
|
251
|
+
})
|
|
252
|
+
|
|
253
|
+
describe('ProjectView Stats', () => {
|
|
254
|
+
it('renders stats when present', () => {
|
|
255
|
+
const project = createProject()
|
|
256
|
+
|
|
257
|
+
const { container } = render(<ProjectView.Stats project={project} />)
|
|
258
|
+
|
|
259
|
+
expect(container.querySelector('[data-folio-view-stats]')).toBeInTheDocument()
|
|
260
|
+
expect(screen.getByText('100 stars')).toBeInTheDocument()
|
|
261
|
+
expect(screen.getByText('20 forks')).toBeInTheDocument()
|
|
262
|
+
})
|
|
263
|
+
|
|
264
|
+
it('does not render when stats is null', () => {
|
|
265
|
+
const project = createProject({ stats: null })
|
|
266
|
+
|
|
267
|
+
const { container } = render(<ProjectView.Stats project={project} />)
|
|
268
|
+
|
|
269
|
+
expect(container.querySelector('[data-folio-view-stats]')).not.toBeInTheDocument()
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
it('does not render when stats object has no values', () => {
|
|
273
|
+
const project = createProject({ stats: {} })
|
|
274
|
+
|
|
275
|
+
const { container } = render(<ProjectView.Stats project={project} />)
|
|
276
|
+
|
|
277
|
+
expect(container.querySelector('[data-folio-view-stats]')).not.toBeInTheDocument()
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
it('renders npm stats', () => {
|
|
281
|
+
const project = createProject({
|
|
282
|
+
stats: { downloads: '5000', version: '3.0.0' }
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
render(<ProjectView.Stats project={project} />)
|
|
286
|
+
|
|
287
|
+
expect(screen.getByText('5000 downloads')).toBeInTheDocument()
|
|
288
|
+
expect(screen.getByText('3.0.0')).toBeInTheDocument()
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
it('renders product hunt stats', () => {
|
|
292
|
+
const project = createProject({
|
|
293
|
+
stats: { upvotes: 300, comments: 45 }
|
|
294
|
+
})
|
|
295
|
+
|
|
296
|
+
render(<ProjectView.Stats project={project} />)
|
|
297
|
+
|
|
298
|
+
expect(screen.getByText('300 upvotes')).toBeInTheDocument()
|
|
299
|
+
expect(screen.getByText('45 comments')).toBeInTheDocument()
|
|
300
|
+
})
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
describe('ProjectView data attributes', () => {
|
|
304
|
+
it('has correct data-folio-view attribute on root', () => {
|
|
305
|
+
const project = createProject()
|
|
306
|
+
|
|
307
|
+
const { container } = render(
|
|
308
|
+
<ProjectView project={project}>
|
|
309
|
+
<span>Content</span>
|
|
310
|
+
</ProjectView>
|
|
311
|
+
)
|
|
312
|
+
|
|
313
|
+
expect(container.querySelector('[data-folio-view]')).toBeInTheDocument()
|
|
314
|
+
})
|
|
315
|
+
|
|
316
|
+
it('has correct data-folio-view-section attributes', () => {
|
|
317
|
+
const project = createProject()
|
|
318
|
+
|
|
319
|
+
const { container } = render(<ProjectView.Section project={project} name="background" />)
|
|
320
|
+
|
|
321
|
+
const section = container.querySelector('[data-folio-view-section]')
|
|
322
|
+
expect(section).toBeInTheDocument()
|
|
323
|
+
expect(section).toHaveAttribute('data-folio-view-section-name', 'background')
|
|
324
|
+
})
|
|
325
|
+
|
|
326
|
+
it('has correct data-folio-view-links attribute', () => {
|
|
327
|
+
const project = createProject()
|
|
328
|
+
|
|
329
|
+
const { container } = render(<ProjectView.Links project={project} />)
|
|
330
|
+
|
|
331
|
+
expect(container.querySelector('[data-folio-view-links]')).toBeInTheDocument()
|
|
332
|
+
})
|
|
333
|
+
|
|
334
|
+
it('has correct data-folio-view-stats attribute', () => {
|
|
335
|
+
const project = createProject()
|
|
336
|
+
|
|
337
|
+
const { container } = render(<ProjectView.Stats project={project} />)
|
|
338
|
+
|
|
339
|
+
expect(container.querySelector('[data-folio-view-stats]')).toBeInTheDocument()
|
|
340
|
+
})
|
|
341
|
+
})
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type { FolioProject } from '../../types'
|
|
2
|
+
|
|
3
|
+
type SectionName = keyof Pick<FolioProject, 'description' | 'background' | 'why' | 'stack' | 'struggles' | 'timeline' | 'posts'>
|
|
4
|
+
|
|
5
|
+
function isValidSectionName(name: string): name is SectionName {
|
|
6
|
+
return ['description', 'background', 'why', 'stack', 'struggles', 'timeline', 'posts'].includes(name)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function ProjectView({
|
|
10
|
+
project,
|
|
11
|
+
onBack,
|
|
12
|
+
children
|
|
13
|
+
}: {
|
|
14
|
+
project: FolioProject
|
|
15
|
+
onBack?: () => void
|
|
16
|
+
children: React.ReactNode
|
|
17
|
+
}) {
|
|
18
|
+
return (
|
|
19
|
+
<div data-folio-view>
|
|
20
|
+
{onBack && <button onClick={onBack}>Back</button>}
|
|
21
|
+
<h2>{project.name}</h2>
|
|
22
|
+
{children}
|
|
23
|
+
</div>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
ProjectView.Section = function ProjectViewSection({
|
|
28
|
+
project,
|
|
29
|
+
name
|
|
30
|
+
}: {
|
|
31
|
+
project: FolioProject
|
|
32
|
+
name: string
|
|
33
|
+
}) {
|
|
34
|
+
if (!isValidSectionName(name)) return null
|
|
35
|
+
|
|
36
|
+
const sectionData = project[name]
|
|
37
|
+
|
|
38
|
+
if (!sectionData) return null
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div data-folio-view-section data-folio-view-section-name={name}>
|
|
42
|
+
{typeof sectionData === 'string' && <>{sectionData}</>}
|
|
43
|
+
{Array.isArray(sectionData) &&
|
|
44
|
+
sectionData.map((item, index) => {
|
|
45
|
+
if (typeof item === 'string') {
|
|
46
|
+
return <span key={index} data-folio-tag>{item}</span>
|
|
47
|
+
}
|
|
48
|
+
if ('type' in item && 'text' in item) {
|
|
49
|
+
const struggle = item as { type: string; text: string }
|
|
50
|
+
return (
|
|
51
|
+
<div key={index} data-folio-struggle data-folio-struggle-type={struggle.type}>
|
|
52
|
+
{struggle.text}
|
|
53
|
+
</div>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
if ('date' in item && ('note' in item || 'title' in item)) {
|
|
57
|
+
if ('note' in item) {
|
|
58
|
+
const timeline = item as { date: string; note: string }
|
|
59
|
+
return (
|
|
60
|
+
<div key={index}>
|
|
61
|
+
<span data-folio-timeline-date>{timeline.date}</span>
|
|
62
|
+
<span data-folio-timeline-note>{timeline.note}</span>
|
|
63
|
+
</div>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
if ('title' in item) {
|
|
67
|
+
const post = item as { title: string; date: string; url?: string }
|
|
68
|
+
return (
|
|
69
|
+
<div key={index}>
|
|
70
|
+
<span data-folio-post-title>{post.title}</span>
|
|
71
|
+
<span data-folio-post-date>{post.date}</span>
|
|
72
|
+
{post.url && (
|
|
73
|
+
<a href={post.url} data-folio-post-link>
|
|
74
|
+
Link
|
|
75
|
+
</a>
|
|
76
|
+
)}
|
|
77
|
+
</div>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return null
|
|
82
|
+
})}
|
|
83
|
+
</div>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
ProjectView.Links = function ProjectViewLinks({ project }: { project: FolioProject }) {
|
|
88
|
+
const links = project.links
|
|
89
|
+
|
|
90
|
+
if (
|
|
91
|
+
!links.github &&
|
|
92
|
+
!links.live &&
|
|
93
|
+
!links.npm &&
|
|
94
|
+
!links.appStore &&
|
|
95
|
+
!links.playStore &&
|
|
96
|
+
!links.productHunt
|
|
97
|
+
) {
|
|
98
|
+
return null
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<div data-folio-view-links>
|
|
103
|
+
{links.github && (
|
|
104
|
+
<a href={links.github} data-folio-link data-folio-link-type="github">
|
|
105
|
+
GitHub
|
|
106
|
+
</a>
|
|
107
|
+
)}
|
|
108
|
+
{links.live && (
|
|
109
|
+
<a href={links.live} data-folio-link data-folio-link-type="live">
|
|
110
|
+
Live
|
|
111
|
+
</a>
|
|
112
|
+
)}
|
|
113
|
+
{links.npm && (
|
|
114
|
+
<a href={links.npm} data-folio-link data-folio-link-type="npm">
|
|
115
|
+
npm
|
|
116
|
+
</a>
|
|
117
|
+
)}
|
|
118
|
+
{links.appStore && (
|
|
119
|
+
<a href={links.appStore} data-folio-link data-folio-link-type="app-store">
|
|
120
|
+
App Store
|
|
121
|
+
</a>
|
|
122
|
+
)}
|
|
123
|
+
{links.playStore && (
|
|
124
|
+
<a href={links.playStore} data-folio-link data-folio-link-type="play-store">
|
|
125
|
+
Play Store
|
|
126
|
+
</a>
|
|
127
|
+
)}
|
|
128
|
+
{links.productHunt && (
|
|
129
|
+
<a href={links.productHunt} data-folio-link data-folio-link-type="product-hunt">
|
|
130
|
+
Product Hunt
|
|
131
|
+
</a>
|
|
132
|
+
)}
|
|
133
|
+
</div>
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
ProjectView.Stats = function ProjectViewStats({ project }: { project: FolioProject }) {
|
|
138
|
+
if (!project.stats) {
|
|
139
|
+
return null
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const hasStats =
|
|
143
|
+
project.stats.stars ||
|
|
144
|
+
project.stats.forks ||
|
|
145
|
+
project.stats.downloads ||
|
|
146
|
+
project.stats.version ||
|
|
147
|
+
project.stats.upvotes ||
|
|
148
|
+
project.stats.comments
|
|
149
|
+
|
|
150
|
+
if (!hasStats) {
|
|
151
|
+
return null
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<div data-folio-view-stats>
|
|
156
|
+
{project.stats.stars && <span data-folio-stat="stars">{project.stats.stars} stars</span>}
|
|
157
|
+
{project.stats.forks && <span data-folio-stat="forks">{project.stats.forks} forks</span>}
|
|
158
|
+
{project.stats.downloads && (
|
|
159
|
+
<span data-folio-stat="downloads">{project.stats.downloads} downloads</span>
|
|
160
|
+
)}
|
|
161
|
+
{project.stats.version && <span data-folio-stat="version">{project.stats.version}</span>}
|
|
162
|
+
{project.stats.upvotes && <span data-folio-stat="upvotes">{project.stats.upvotes} upvotes</span>}
|
|
163
|
+
{project.stats.comments && <span data-folio-stat="comments">{project.stats.comments} comments</span>}
|
|
164
|
+
</div>
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export { ProjectView }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ProjectView/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ProjectView/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ProjectView } from './ProjectView'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,OAAO,CAAA;AACrB,cAAc,SAAS,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,OAAO,CAAA;AACrB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineProjects.d.ts","sourceRoot":"","sources":["../../src/lib/defineProjects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEjD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,iBAAiB,EAAE,CAEjF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineProjects.js","sourceRoot":"","sources":["../../src/lib/defineProjects.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,cAAc,CAAC,QAA6B;IAC1D,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|