Skip to content

Commit

Permalink
Add homepage (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicfv authored Mar 20, 2024
1 parent 7c862f1 commit ac36969
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 2 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/home/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">

<head>
<title>nicfv | npm</title>
<meta charset="UTF-8">
<meta name="description" content="nicfv's public NPM packages in one repository">
<meta name="keywords" content="npm">
<meta name="author" content="Nicolas Ventura">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="main.css">
<script type="text/javascript" src="index.js"></script>
</head>

<body>
</body>

</html>
21 changes: 21 additions & 0 deletions .github/workflows/home/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const packages = {};

window.addEventListener('load', init);

function init() {
for (let package in packages) {
const a = document.createElement('a'),
h1 = document.createElement('h1'),
h2a = document.createElement('h2'),
h2b = document.createElement('h2');
a.href = '/' + packages[package].dir;
h1.textContent = package + ' - v' + packages[package].ver;
h2a.textContent = 'Updated ' + new Date(packages[package].time * 1e3).toDateString();
h2b.textContent = packages[package].desc;
a.appendChild(h1);
a.appendChild(h2a);
a.appendChild(h2b);
document.body.appendChild(a);
console.log(package, packages[package]);
}
}
38 changes: 38 additions & 0 deletions .github/workflows/home/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
* {
outline: none;
border-collapse: collapse;
box-sizing: border-box;
}

body {
display: flex;
flex-wrap: wrap;
justify-content: center;
font-family: monospace;
background: #ddd;
}

a {
margin: 1rem;
padding: 1rem;
background: slategray;
text-decoration: none;
cursor: pointer;
border-radius: 0.25rem;
width: 20rem;
color: white;
}

a:hover {
background: slateblue;
}

a:active {
background: steelblue;
}

@media (prefers-color-scheme: dark) {
body {
background: #222;
}
}
11 changes: 10 additions & 1 deletion .github/workflows/run
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ if "${publish}" ; then
exit 1
else
mkdir .docs || exit 1
cp .github/workflows/home/* .docs
npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
fi
fi

for dir in */ ; do
npx -y wag "Checking directory '${dir}'"
echo -e "\n=== Checking directory '${dir}' ===\n"
# Skip directories that are not an npm project
npm --silent v "${dir}" || {
echo "${dir} is not an NPM project"
Expand Down Expand Up @@ -60,6 +61,14 @@ for dir in */ ; do
# package date with the current timestamp
package_date=$(date +%s)
fi
# Add package details to homepage script
{
echo "packages['${package_name//"'"/"\\'"}'] = {};"
echo "packages['${package_name//"'"/"\\'"}'].desc = '${package_desc//"'"/"\\'"}';"
echo "packages['${package_name//"'"/"\\'"}'].time = '${package_date//"'"/"\\'"}';"
echo "packages['${package_name//"'"/"\\'"}'].ver = '${local_version//"'"/"\\'"}';"
echo "packages['${package_name//"'"/"\\'"}'].dir = '${dir//"'"/"\\'"}';"
} >> '../.docs/index.js'
# Store current readme content, copy over the
# template readme file, and replace variables
echo 'Generating readme...'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/template.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[Docs](https://npm.nicfv.com/%DIR%) | [GitHub](https://github.com/nicfv/npm/tree/main/%DIR%) | [npm](https://www.npmjs.com/package/%NAME%) | [Changelog](https://github.com/nicfv/npm/blob/main/%DIR%/CHANGELOG.md) | %DESC%
[Home](/) | [Docs](https://npm.nicfv.com/%DIR%) | [GitHub](https://github.com/nicfv/npm/tree/main/%DIR%) | [npm](https://www.npmjs.com/package/%NAME%) | [Changelog](https://github.com/nicfv/npm/blob/main/%DIR%/CHANGELOG.md) | %DESC%

![NPM Downloads](https://img.shields.io/npm/dt/%NAME%)
![NPM Version](https://img.shields.io/npm/v/%NAME%)
Expand Down

0 comments on commit ac36969

Please sign in to comment.