From c2c676ce1918d854c7c6d932a46e4e35af00ced6 Mon Sep 17 00:00:00 2001 From: tenkuma Date: Tue, 28 Oct 2025 19:47:12 -0300 Subject: [PATCH 1/2] Finished code to get GitHub OAuth token and fetch project releases at build time. --- .gitignore | 4 +- eleventy.config.js | 32 ++++- gen-github-token.cjs | 89 +++++++++++++ package-lock.json | 205 +++++++++++++++++++++++++++++ package.json | 3 + src/_includes/featured.njk | 2 +- src/_includes/project.njk | 23 +++- src/assets/stylesheets/project.css | 8 ++ src/assets/stylesheets/styles.css | 29 ++-- 9 files changed, 374 insertions(+), 21 deletions(-) create mode 100644 gen-github-token.cjs diff --git a/.gitignore b/.gitignore index f33e0b6..583edf9 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,6 @@ # Visual Studio Code /.vscode -.history \ No newline at end of file +.history + +.env \ No newline at end of file diff --git a/eleventy.config.js b/eleventy.config.js index 5822778..2b1ad2b 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -1,12 +1,38 @@ import elasticlunr from 'elasticlunr'; import fs from 'fs'; import path from 'path'; +import fetch from "node-fetch"; +import 'dotenv/config'; let allPlugins = []; const isProd = process.env.ELEVENTY_ENV === "production"; const pathPrefix = isProd ? "/neoBeta/" : "/"; export default function (eleventyConfig) { + eleventyConfig.addNunjucksAsyncFilter("githubReleases", async function(owner, repo, callback) { + const token = process.env.GITHUB_ACCESS_TOKEN; + if (!owner || !repo) return callback(null, []); + + const url = `https://api.github.com/repos/${owner}/${repo}/releases`; + + try { + const res = await fetch(url, { + headers: { + Authorization: `Bearer ${token}`, + Accept: "application/vnd.github+json", + "User-Agent": "eleventy-build" + } + }); + if (!res.ok) return callback(null, [ name = "Error fetching releases for GitHub project." ]); + const data = await res.json(); + callback(null, data); + } catch (err) { + console.error(err); + callback(null, []); + } + }); + + eleventyConfig.setInputDirectory("src"); eleventyConfig.setOutputDirectory("public"); eleventyConfig.addPassthroughCopy("src/projects/**/*.png"); @@ -21,7 +47,7 @@ export default function (eleventyConfig) { eleventyConfig.addCollection("projects", function(collection) { return collection.getFilteredByGlob("src/projects/*/*.md"); }); - + eleventyConfig.addGlobalData("pathPrefix", pathPrefix) eleventyConfig.addGlobalData("eleventyComputed", { @@ -43,8 +69,8 @@ export default function (eleventyConfig) { return data.layout; }, projectSlug: data => { - const url = data.page?.url || data.page?.filePathStem || ""; - return url.replace(/\/$/,'').split('/').filter(Boolean).pop() || null; + const url = data.page?.url || data.page?.filePathStem || ""; + return url.replace(/\/$/,'').split('/').filter(Boolean).pop() || null; } }); diff --git a/gen-github-token.cjs b/gen-github-token.cjs new file mode 100644 index 0000000..50ad38a --- /dev/null +++ b/gen-github-token.cjs @@ -0,0 +1,89 @@ +require('dotenv').config(); +const http = require('http'); +const { URL } = require('url'); +const fetch = require('node-fetch'); +const open = (...args) => import('open').then(m => m.default(...args)); +const fs = require('fs'); +const path = require('path'); + +const { + GITHUB_CLIENT_ID, + GITHUB_CLIENT_SECRET, + GITHUB_OAUTH_SCOPES = 'repo,user', +} = process.env; + +if (!GITHUB_CLIENT_ID || !GITHUB_CLIENT_SECRET) { + console.error('Set GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET in .env'); + process.exit(1); +} + +const PORT = 9876; +const REDIRECT_URI = `http://localhost:${PORT}/`; +const STATE = String(Math.random()).slice(2); + +function appendEnv(key, value) { + const envPath = path.resolve(process.cwd(), '.env'); + const line = `\n${key}=${value}\n`; + fs.appendFileSync(envPath, line, { encoding: 'utf8' }); + console.log(`${key} appended to .env`); +} + +async function exchangeCodeForToken(code) { + const tokenUrl = 'https://github.com/login/oauth/access_token'; + const res = await fetch(tokenUrl, { + method: 'POST', + headers: { Accept: 'application/json', 'Content-Type': 'application/json' }, + body: JSON.stringify({ + client_id: GITHUB_CLIENT_ID, + client_secret: GITHUB_CLIENT_SECRET, + code, + redirect_uri: REDIRECT_URI, + state: STATE, + }), + }); + if (!res.ok) throw new Error(`Token exchange failed: ${res.status}`); + const data = await res.json(); + if (data.error) throw new Error(`Token error: ${data.error_description || data.error}`); + return data.access_token; +} + +const server = http.createServer(async (req, res) => { + try { + const reqUrl = new URL(req.url, `http://localhost:${PORT}`); + const code = reqUrl.searchParams.get('code'); + const state = reqUrl.searchParams.get('state'); + + if (!code || state !== STATE) { + res.writeHead(400, { 'Content-Type': 'text/plain' }); + res.end('Invalid request'); + return; + } + + res.writeHead(200, { 'Content-Type': 'text/plain' }); + res.end('Authorization received. You can close this window.'); + + console.log('Received code, exchanging for token...'); + const token = await exchangeCodeForToken(code); + console.log('Access token received:', token); + + // Append token to .env (BE CAREFUL) + appendEnv('GITHUB_ACCESS_TOKEN', token); + } catch (err) { + console.error('Error handling OAuth callback:', err); + } finally { + server.close(); + } +}); + +server.listen(PORT, async () => { + const authUrl = + `https://github.com/login/oauth/authorize` + + `?client_id=${encodeURIComponent(GITHUB_CLIENT_ID)}` + + `&redirect_uri=${encodeURIComponent(REDIRECT_URI)}` + + `&scope=${encodeURIComponent(GITHUB_OAUTH_SCOPES)}` + + `&state=${encodeURIComponent(STATE)}`; + + console.log('Opening browser for GitHub authorization...'); + await open(authUrl); + console.log(`Listening for OAuth callback at ${REDIRECT_URI}`); +}); diff --git a/package-lock.json b/package-lock.json index 2859e93..d4ec3b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,10 @@ "license": "Unlicense", "dependencies": { "@11ty/eleventy": "^3.1.2", + "dotenv": "^17.2.3", "elasticlunr": "^0.9.5", + "node-fetch": "^2.7.0", + "open": "^10.2.0", "sass": "1.93.2" } }, @@ -702,6 +705,21 @@ "node": ">=8" } }, + "node_modules/bundle-name": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-4.1.0.tgz", + "integrity": "sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q==", + "license": "MIT", + "dependencies": { + "run-applescript": "^7.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/chokidar": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", @@ -758,6 +776,46 @@ } } }, + "node_modules/default-browser": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-5.2.1.tgz", + "integrity": "sha512-WY/3TUME0x3KPYdRRxEJJvXRHV4PyPoUsxtZa78lwItwRQRHhd2U9xOscaT/YTf8uCXIAjeJOFBVEh/7FtD8Xg==", + "license": "MIT", + "dependencies": { + "bundle-name": "^4.1.0", + "default-browser-id": "^5.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser-id": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-5.0.0.tgz", + "integrity": "sha512-A6p/pu/6fyBcA1TRz/GqWYPViplrftcW2gZC9q79ngNCKAeR/X3gcEdXQHl4KNXV+3wgIJ1CPkJQ3IHM6lcsyA==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/define-lazy-prop": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz", + "integrity": "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", @@ -853,6 +911,18 @@ "url": "https://github.com/fb55/domutils?sponsor=1" } }, + "node_modules/dotenv": { + "version": "17.2.3", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.2.3.tgz", + "integrity": "sha512-JVUnt+DUIzu87TABbhPmNfVdBDt18BLOWjMUFJMSi/Qqg7NTYtabbvSNJGOJ7afbRuv9D/lngizHtP7QyLQ+9w==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -1225,6 +1295,21 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/is-docker": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", + "integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==", + "license": "MIT", + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", @@ -1255,6 +1340,24 @@ "node": ">=0.10.0" } }, + "node_modules/is-inside-container": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz", + "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==", + "license": "MIT", + "dependencies": { + "is-docker": "^3.0.0" + }, + "bin": { + "is-inside-container": "cli.js" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-json": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-json/-/is-json-2.0.1.tgz", @@ -1270,6 +1373,21 @@ "node": ">=0.12.0" } }, + "node_modules/is-wsl": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.0.tgz", + "integrity": "sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw==", + "license": "MIT", + "dependencies": { + "is-inside-container": "^1.0.0" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/iso-639-1": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/iso-639-1/-/iso-639-1-3.1.5.tgz", @@ -1527,6 +1645,26 @@ "license": "MIT", "optional": true }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, "node_modules/node-retrieve-globals": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/node-retrieve-globals/-/node-retrieve-globals-6.0.1.tgz", @@ -1593,6 +1731,24 @@ "node": ">= 0.8" } }, + "node_modules/open": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/open/-/open-10.2.0.tgz", + "integrity": "sha512-YgBpdJHPyQ2UE5x+hlSXcnejzAvD0b22U2OuAP+8OnlJT+PjWPxtgmGqKKc+RgTM63U9gN0YzrYc71R2WT/hTA==", + "license": "MIT", + "dependencies": { + "default-browser": "^5.2.1", + "define-lazy-prop": "^3.0.0", + "is-inside-container": "^1.0.0", + "wsl-utils": "^0.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/parse-srcset": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/parse-srcset/-/parse-srcset-1.0.2.tgz", @@ -1728,6 +1884,18 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/run-applescript": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-7.1.0.tgz", + "integrity": "sha512-DPe5pVFaAsinSaV6QjQ6gdiedWDcRCbUuiQfQa2wmWV7+xC9bGulGI8+TdRmoFkAPaBXk8CrAbnlY2ISniJ47Q==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/sass": { "version": "1.93.2", "resolved": "https://registry.npmjs.org/sass/-/sass-1.93.2.tgz", @@ -1935,6 +2103,12 @@ "node": ">=0.6" } }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, "node_modules/uc.micro": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", @@ -1956,6 +2130,22 @@ "integrity": "sha512-IGjKp/o0NL3Bso1PymYURCJxMPNAf/ILOpendP9f5B6e1rTJgdgiOvgfoT8VxCAdY+Wisb9uhGaJJf3yZ2V9nw==", "license": "MIT" }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/ws": { "version": "8.18.3", "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz", @@ -1976,6 +2166,21 @@ "optional": true } } + }, + "node_modules/wsl-utils": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/wsl-utils/-/wsl-utils-0.1.0.tgz", + "integrity": "sha512-h3Fbisa2nKGPxCpm89Hk33lBLsnaGBvctQopaBSOW/uIs6FTe1ATyAnKFJrzVs9vpGdsTe73WF3V4lIsk4Gacw==", + "license": "MIT", + "dependencies": { + "is-wsl": "^3.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } } } } diff --git a/package.json b/package.json index ef3f541..9464bde 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,10 @@ "homepage": "https://github.com/adrianvic/neoBeta#readme", "dependencies": { "@11ty/eleventy": "^3.1.2", + "dotenv": "^17.2.3", "elasticlunr": "^0.9.5", + "node-fetch": "^2.7.0", + "open": "^10.2.0", "sass": "1.93.2" } } diff --git a/src/_includes/featured.njk b/src/_includes/featured.njk index d532513..d68ab89 100644 --- a/src/_includes/featured.njk +++ b/src/_includes/featured.njk @@ -15,7 +15,7 @@

{{ projectData.data.name }}

-

by {{ projectData.data.author }}

+

by {{ projectData.data.author }}

{{ projectData.data.subtitle }}
diff --git a/src/_includes/project.njk b/src/_includes/project.njk index 5e1750b..e2ee03a 100644 --- a/src/_includes/project.njk +++ b/src/_includes/project.njk @@ -16,11 +16,30 @@ styles: ["project"] - {% if links or docs or images or releases %} + {% if links or docs or images or releaseType %}
{% include "project_image.njk" %}
-

Here's what we found:

+

Here's what we found about this project:

+ {% if releaseType %} +

+ {% if releaseType == "github" %} + {% set releases = githubRepoOwner | githubReleases(githubRepoName) %} + Releases fetched from GitHub:
+

+ {% for release in releases %} + {{ release.name }} + {% endfor %} +
+ {% endif %} + {% if releaseType == "local" %} +

{{ releases | length }} releases.

+ {% for label, addr in releases %} + {{ label }} + {% endfor %} + {% endif %} +

+ {% endif %} {% if links %}

{{ links | length }} links.

    diff --git a/src/assets/stylesheets/project.css b/src/assets/stylesheets/project.css index 7a8f9ae..3e6cf28 100644 --- a/src/assets/stylesheets/project.css +++ b/src/assets/stylesheets/project.css @@ -100,6 +100,14 @@ overflow-y: auto; } +.projectInfoGitHubReleases.less { + overflow: hidden; + display: -webkit-box; + line-clamp: 2; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical +} + @media only screen and (max-width: 1280px) { #projectImagesAndInfo { flex-direction: column; diff --git a/src/assets/stylesheets/styles.css b/src/assets/stylesheets/styles.css index b82afd5..e743958 100644 --- a/src/assets/stylesheets/styles.css +++ b/src/assets/stylesheets/styles.css @@ -50,8 +50,8 @@ main { } /* main:last-child { - margin-bottom: 0px; - padding-bottom: 0px; +margin-bottom: 0px; +padding-bottom: 0px; } */ button { @@ -174,11 +174,12 @@ hr { } .featuredProjectSubtitle { -overflow: hidden; - width: 100%; - display: -webkit-box; - -webkit-line-clamp: 2; - -webkit-box-orient: vertical + overflow: hidden; + width: 100%; + display: -webkit-box; + line-clamp: 2; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical } .featuredProjectSubtitle { @@ -238,7 +239,7 @@ h1, h2, h3 { 0%,100% { background-position: 0 0; } - + 50% { background-position: 100% 0; } @@ -248,25 +249,25 @@ h1, h2, h3 { #everythingHelper { flex-direction: column; } - + aside { width: 100%; } - + #projectTitle { font-size: larger; } - + #headerLinksAndTitle { flex-direction: row; } - + #headerLinks { margin-left: 2em; } - + } @media only screen and (max-width: 300px) { - + } \ No newline at end of file From 05fd995eddf7947407c17502bc1810ab07cf4da1 Mon Sep 17 00:00:00 2001 From: tenkuma Date: Wed, 29 Oct 2025 20:40:26 -0300 Subject: [PATCH 2/2] Added dedicated virtual template for releases. --- eleventy.config.js | 11 +++--- src/_includes/project.njk | 21 +---------- src/_virtual/releases.njk | 29 +++++++++++++++ src/assets/stylesheets/styles.css | 2 ++ src/contribute.md | 35 ++++++++++++++----- ...ample_documentation.md => installation.md} | 0 src/projects/ghostsandstuff/index.json | 7 ++-- 7 files changed, 70 insertions(+), 35 deletions(-) create mode 100644 src/_virtual/releases.njk rename src/projects/ghostsandstuff/docs/{example_documentation.md => installation.md} (100%) diff --git a/eleventy.config.js b/eleventy.config.js index 2b1ad2b..900d4a7 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -7,6 +7,7 @@ import 'dotenv/config'; let allPlugins = []; const isProd = process.env.ELEVENTY_ENV === "production"; const pathPrefix = isProd ? "/neoBeta/" : "/"; +const buildTime = new Date(Date.now()).toISOString(); export default function (eleventyConfig) { eleventyConfig.addNunjucksAsyncFilter("githubReleases", async function(owner, repo, callback) { @@ -31,8 +32,7 @@ export default function (eleventyConfig) { callback(null, []); } }); - - + eleventyConfig.setInputDirectory("src"); eleventyConfig.setOutputDirectory("public"); eleventyConfig.addPassthroughCopy("src/projects/**/*.png"); @@ -43,13 +43,14 @@ export default function (eleventyConfig) { eleventyConfig.addPassthroughCopy("src/authors/**/*.jpeg"); eleventyConfig.addPassthroughCopy("src/assets"); eleventyConfig.addPassthroughCopy({ "src/favicon/*" : "/" }); + eleventyConfig.addGlobalData("pathPrefix", pathPrefix); + eleventyConfig.addGlobalData("buildTime", buildTime); eleventyConfig.addCollection("projects", function(collection) { - return collection.getFilteredByGlob("src/projects/*/*.md"); + const col = collection.getFilteredByGlob("src/projects/*/*.md"); + return col; }); - eleventyConfig.addGlobalData("pathPrefix", pathPrefix) - eleventyConfig.addGlobalData("eleventyComputed", { projectData: (data) => { const inputPath = data.page.inputPath; diff --git a/src/_includes/project.njk b/src/_includes/project.njk index e2ee03a..535d3c3 100644 --- a/src/_includes/project.njk +++ b/src/_includes/project.njk @@ -14,32 +14,13 @@ styles: ["project"]

{{ subtitle }}

- + {% if links or docs or images or releaseType %}
{% include "project_image.njk" %}

Here's what we found about this project:

- {% if releaseType %} -

- {% if releaseType == "github" %} - {% set releases = githubRepoOwner | githubReleases(githubRepoName) %} - Releases fetched from GitHub:
-

- {% for release in releases %} - {{ release.name }} - {% endfor %} -
- {% endif %} - {% if releaseType == "local" %} -

{{ releases | length }} releases.

- {% for label, addr in releases %} - {{ label }} - {% endfor %} - {% endif %} -

- {% endif %} {% if links %}

{{ links | length }} links.

    diff --git a/src/_virtual/releases.njk b/src/_virtual/releases.njk new file mode 100644 index 0000000..37d475b --- /dev/null +++ b/src/_virtual/releases.njk @@ -0,0 +1,29 @@ +--- +pagination: + data: collections.projects + size: 1 + alias: project +permalink: "{{ project.url }}releases.html" +layout: base.njk +--- +

    Releases for {{ project.data.name }}

    + +{% if project.data.releaseType %} +

    + {% if project.data.releaseType == "github" %} + {% set releases = project.data.githubRepoOwner | githubReleases(project.data.githubRepoName) %} + Releases fetched from GitHub at {{ buildTime }}:
    + {% for release in releases %} +

    {{ release.name }}

    + {% endfor %} + {% endif %} + {% if project.data.releaseType == "local" %} +

    {{ project.data.releases | length }} releases.

    + {% for label, addr in project.data.releases %} +

    {{ label }}

    + {% endfor %} + {% endif %} +

    +{% else %} +

    Could not find any release for this project...

    +{% endif %} diff --git a/src/assets/stylesheets/styles.css b/src/assets/stylesheets/styles.css index e743958..98f38bf 100644 --- a/src/assets/stylesheets/styles.css +++ b/src/assets/stylesheets/styles.css @@ -70,6 +70,8 @@ code { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; border-radius: 2px; display: inline-block; + max-width: 100%; + overflow-x: auto; } input, select { diff --git a/src/contribute.md b/src/contribute.md index 02b96d7..c936590 100644 --- a/src/contribute.md +++ b/src/contribute.md @@ -15,20 +15,39 @@ neoBeta is an open-source content management system. There are various ways you - *tags* - whether your project is a plugin or mod. ### Optional metadata fields -Please fill as many fields as possible. - - *downloadLink* - link for when you click the download link. +Please fill as many fields as possible. - *images* - lists of image files names or URLs that will appear in the project page. - *logo* - your logo file name or URL. +### Releases metadata + - *releasesType* - wheter your project uses `local` releases or `github`. +For local releases: + - *releases* - a list of relases labels and links. +For GitHub releases: + - *githubRepoOwner* - username of the repo owner. + - *githubReponame* - name of the repository. + ### Config file example ``` { "name": "Ghosts 'n Stuff", - "subtitle": "Miscellaneous additions to your server.", + "subtitle": "Miscellaneous additions to your Minecraft server.", "author": "tenkuma", - "downloadLink": "https://example.com", - "images": "["image1.png", "image2.png", "image3.png"]", + "downloadLink": "https://modrinth.com/plugin/ghosts/versions", + "images": ["anti-spam.png", "rainbow-chat.png", "skibidi-blocker.png"], "logo": "logo.png", - "tags": ["plugin", "mod"] -} -``` \ No newline at end of file + "tags": ["plugin"], + "links": { + "GitHub": "https://github.com/adrianvic/ghostsandstuff", + "Disroot Git": "https://git.disroot.org/adrianvictor/ghostsandstuff" + }, + "docs": { + "Installation" : "docs/installation" + }, + "releaseType": "github or local", + "githubRepoOwner": "adrianvic", + "githubRepoName": "ghostsandstuff", + "releases": { + "test release": "https://example.com/" + } +}``` \ No newline at end of file diff --git a/src/projects/ghostsandstuff/docs/example_documentation.md b/src/projects/ghostsandstuff/docs/installation.md similarity index 100% rename from src/projects/ghostsandstuff/docs/example_documentation.md rename to src/projects/ghostsandstuff/docs/installation.md diff --git a/src/projects/ghostsandstuff/index.json b/src/projects/ghostsandstuff/index.json index 24aee96..c81edea 100644 --- a/src/projects/ghostsandstuff/index.json +++ b/src/projects/ghostsandstuff/index.json @@ -11,6 +11,9 @@ "Disroot Git": "https://git.disroot.org/adrianvictor/ghostsandstuff" }, "docs": { - "Installation" : "docs/example_documentation" - } + "Installation" : "docs/installation" + }, + "releaseType": "github", + "githubRepoOwner": "adrianvic", + "githubRepoName": "ghostsandstuff" } \ No newline at end of file