Skip to content

Commit df4300e

Browse files
committed
Added package detail page skeleton.
1 parent f756368 commit df4300e

File tree

17 files changed

+1190
-235
lines changed

17 files changed

+1190
-235
lines changed

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
**/node_modules
2+
**/dist
3+
**/public
4+
!.vuepress

.eslintrc.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
node: true
5+
},
6+
extends: [
7+
"eslint:recommended",
8+
"plugin:vue/recommended",
9+
"prettier/vue",
10+
"plugin:prettier/recommended"
11+
],
12+
rules: {
13+
"vue/component-name-in-template-casing": ["error", "PascalCase"],
14+
"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
15+
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off"
16+
}
17+
}

docs/.vuepress/config.js

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,72 @@
1-
const { description } = require('../../package')
1+
/* eslint-disable no-unused-vars */
2+
const { description } = require("../../package");
3+
const packages = require("./packages");
24

35
module.exports = {
4-
5-
title: 'OpenUPM',
6+
title: "OpenUPM",
67
description: description,
78
head: [
8-
['meta', { name: 'theme-color', content: '#3eaf7c' }],
9-
['meta', { name: 'apple-mobile-web-app-capable', content: 'yes' }],
10-
['meta', { name: 'apple-mobile-web-app-status-bar-style', content: 'black' }],
11-
['link', { rel: "stylesheet", href: "https://use.typekit.net/uwx2pxu.css"}],
9+
["meta", { name: "theme-color", content: "#3eaf7c" }],
10+
["meta", { name: "apple-mobile-web-app-capable", content: "yes" }],
11+
[
12+
"meta",
13+
{ name: "apple-mobile-web-app-status-bar-style", content: "black" }
14+
],
15+
[
16+
"link",
17+
{ rel: "stylesheet", href: "https://use.typekit.net/uwx2pxu.css" }
18+
],
19+
[
20+
"link",
21+
{
22+
rel: "stylesheet",
23+
href:
24+
"https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
25+
}
26+
]
1227
],
1328

1429
themeConfig: {
15-
repo: 'https://github.com/openupm/openupm',
30+
repo: "https://github.com/openupm/openupm",
1631
editLinks: false,
17-
docsDir: '',
18-
editLinkText: '',
32+
docsDir: "",
33+
editLinkText: "",
1934
lastUpdated: false,
20-
logo: '/images/openupm-icon-128.png',
35+
logo: "/images/openupm-icon-128.png",
2136
nav: [
2237
{
23-
text: 'Packages',
24-
link: '/packages/'
38+
text: "Packages",
39+
link: "/packages/"
2540
},
2641
{
27-
text: 'Docs',
28-
link: '/docs/'
42+
text: "Docs",
43+
link: "/docs/"
2944
},
3045
{
31-
text: 'Donate',
32-
link: '/donate/'
46+
text: "Donate",
47+
link: "/donate/"
3348
},
3449
{
35-
text: 'Login',
36-
link: '/login/'
37-
},
50+
text: "Login",
51+
link: "/login/"
52+
}
3853
]
3954
},
4055

4156
/**
4257
* Apply plugins,ref:https://v1.vuepress.vuejs.org/zh/plugin/
4358
*/
44-
plugins: [
45-
'@vuepress/plugin-back-to-top',
46-
'@vuepress/plugin-medium-zoom',
47-
],
59+
plugins: ["@vuepress/plugin-back-to-top", "@vuepress/plugin-medium-zoom"],
4860

4961
chainWebpack: (config, isServer) => {
50-
config.module.rule('yaml')
62+
config.module
63+
.rule("yaml")
5164
.test(/\.ya?ml$/)
52-
.use('js-yaml-loader')
53-
.loader('js-yaml-loader')
65+
.use("js-yaml-loader")
66+
.loader("js-yaml-loader");
5467
},
55-
}
68+
69+
async additionalPages() {
70+
return await packages.additionalPages();
71+
}
72+
};

docs/.vuepress/packages.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Packages
2+
const fs = require("fs");
3+
const parseGitHubUrl = require("parse-github-url");
4+
const path = require("path");
5+
const spdx = require("spdx-license-list");
6+
const yaml = require("js-yaml");
7+
8+
const packagesDir = path.resolve(__dirname, "../../packages");
9+
10+
module.exports = {
11+
async additionalPages() {
12+
return (
13+
fs
14+
.readdirSync(packagesDir)
15+
// Find paths with *.ya?ml ext.
16+
.filter(p => (p.match(/.*\.(ya?ml)$/) || [])[1] !== undefined)
17+
// Convert to page info.
18+
.map(function(p) {
19+
try {
20+
const absPath = path.resolve(packagesDir, p);
21+
// Load package yaml.
22+
const doc = yaml.safeLoad(fs.readFileSync(absPath, "utf8"));
23+
const ghUrl = parseGitHubUrl(doc.repoUrl);
24+
doc.repo = ghUrl.repo;
25+
doc.owner = ghUrl.owner;
26+
doc.ownerUrl = "https://" + ghUrl.hostname + "/" + ghUrl.owner;
27+
if (doc.hunter) {
28+
doc.hunterUrl = "https://" + ghUrl.hostname + "/" + doc.hunter;
29+
} else {
30+
doc.hunter = "anonymous";
31+
doc.hunterUrl = null;
32+
}
33+
if (doc.licenseSpdxId) {
34+
doc.licenseName = spdx[doc.licenseSpdxId]["name"];
35+
}
36+
// Frontmatter.
37+
const frontmatter = {
38+
layout: "PackageDetail",
39+
package: doc
40+
};
41+
// Page info.
42+
const pageUrl = "/packages/" + p.match(/(.*)\.(ya?ml)$/)[1];
43+
const pageContent =
44+
"---\n" + yaml.safeDump(frontmatter) + "\n---\n";
45+
return { path: pageUrl, content: pageContent };
46+
} catch (e) {
47+
console.error(e);
48+
return null;
49+
}
50+
})
51+
// Filter out empty entry.
52+
.filter(p => p)
53+
);
54+
}
55+
};

docs/.vuepress/theme/components/Footer.vue

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99
<div class="column col-2 col-md-2 col-sm-4">
1010
<h5>About</h5>
1111
<ul>
12-
<li v-for="link in aboutLinks">
12+
<li v-for="(link, index) in aboutLinks" :key="index">
1313
<NavLink class :item="link" />
1414
</li>
1515
</ul>
1616
</div>
1717
<div class="column col-2 col-md-2 col-sm-4">
1818
<h5>Connect</h5>
1919
<ul>
20-
<li v-for="link in connectLinks">
20+
<li v-for="(link, index) in connectLinks" :key="index">
2121
<NavLink class :item="link" />
2222
</li>
2323
</ul>
2424
</div>
2525
<div class="column col-2 col-md-2 col-sm-4">
2626
<h5>Operation</h5>
2727
<ul>
28-
<li v-for="link in opLinks">
28+
<li v-for="(link, index) in opLinks" :key="index">
2929
<NavLink class :item="link" />
3030
</li>
3131
</ul>
@@ -90,30 +90,39 @@ export default {
9090
background-color $primaryColor
9191
color $lightTextColor
9292
padding 1.7rem 0
93+
9394
.inner
9495
max-width $pageWidth
9596
margin 0 auto
97+
9698
h5
9799
font-weight 600
98100
margin-bottom 1rem
101+
99102
h5, p, ul, li
100103
font-size 0.7rem
104+
101105
ul
102106
list-style none
103107
margin 0 0 0.7rem
104108
line-height 1.7
109+
105110
li
106111
margin-top 0
112+
107113
.input-group
108114
margin-bottom 0.7rem
115+
109116
.form-input
110117
font-size 0.7rem
111118
border-color white
119+
112120
.input-group-btn
113121
font-size 0.7rem
114122
padding-left 0.8rem
115123
padding-right 0.8rem
116124
border-color white
125+
117126
a
118127
color $lightTextColor !important
119-
</style>
128+
</style>

docs/.vuepress/theme/components/Navbar.vue

Lines changed: 43 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -13,69 +13,55 @@ export default {
1313
</script>
1414

1515
<style lang="stylus">
16-
.navbar {
17-
.logo {
18-
height: 2.1rem;
19-
width: 2.1rem;
20-
min-width: auto;
21-
margin-right: 0.3rem;
22-
}
16+
.navbar
17+
.logo
18+
height 2.1rem
19+
width 2.1rem
20+
min-width auto
21+
margin-right 0.3rem
2322
24-
.site-name {
25-
font-family: $titleFontFamily;
26-
font-size: 1.1rem;
27-
color: $accentColor;
28-
}
23+
.site-name
24+
font-family $titleFontFamily
25+
font-size 1.1rem
26+
color $accentColor
2927
30-
a.router-link-active, .nav-item a {
31-
&, &:focus, &:hover, &:visited, &:active, &.active, &.router-link-active {
32-
color: $accentColor;
33-
text-decoration: none;
34-
}
35-
}
28+
a.router-link-active, .nav-item a
29+
&, &:focus, &:hover, &:visited, &:active, &.active, &.router-link-active
30+
color $accentColor
31+
text-decoration none
3632
37-
.nav-links {
38-
.nav-item {
39-
line-height: 1.8rem;
40-
}
33+
.nav-links
34+
.nav-item
35+
line-height 1.8rem
4136
42-
a {
43-
font-family: $titleFontFamily;
44-
font-size: 0.7rem;
45-
font-weight: 600;
46-
color: $accentColor;
47-
}
48-
}
37+
a
38+
font-family $titleFontFamily
39+
font-size 0.7rem
40+
font-weight 600
41+
color $accentColor
4942
50-
.search-box {
51-
input {
52-
height: 1.8rem;
53-
line-height: 1.8rem;
54-
font-size: 0.7rem;
55-
background-size: 0.8rem;
56-
}
43+
.search-box
44+
input
45+
height 1.8rem
46+
line-height 1.8rem
47+
font-size 0.7rem
48+
background-size 0.8rem
5749
58-
.suggestions {
59-
top: 1.2rem;
60-
padding: 0.3rem;
61-
}
50+
.suggestions
51+
top 1.2rem
52+
padding 0.3rem
6253
63-
.suggestion {
64-
margin-top: 0.2rem;
65-
padding: 0.3rem 0.5rem;
66-
line-height: 1.2;
54+
.suggestion
55+
margin-top 0.2rem
56+
padding 0.3rem 0.5rem
57+
line-height 1.2
6758
68-
a {
69-
font-size: 0.7rem;
70-
}
71-
}
72-
}
73-
}
59+
a
60+
font-size 0.7rem
7461
75-
.wip {
76-
position: fixed;
77-
z-index: 1000;
78-
left: 200px;
79-
top: 8px;
80-
}
81-
</style>
62+
.wip
63+
position fixed
64+
z-index 1000
65+
left 200px
66+
top 8px
67+
</style>

docs/.vuepress/theme/enhanceApp.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-unused-vars */
12
/**
23
* Client app enhancement file.
34
*
@@ -11,4 +12,4 @@ export default ({
1112
siteData // site metadata
1213
}) => {
1314
// ...apply enhancements for the site.
14-
}
15+
};

docs/.vuepress/theme/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
extend: '@vuepress/theme-default',
3-
}
2+
extend: "@vuepress/theme-default"
3+
};

0 commit comments

Comments
 (0)