Fixed compatibility issues with GitHub Pages.

This commit is contained in:
天クマ 2025-10-28 14:08:09 -03:00
commit 5bceb5af72
14 changed files with 58 additions and 101 deletions

View file

@ -1,36 +0,0 @@
name: Build and Deploy
on:
push:
branches: ['master']
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['20']
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install packages
run: npm ci
- name: Run npm build
run: npm run build:prod
- name: Deploy to gh-pages
uses: peaceiris/actions-gh-pages@v4
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}

View file

@ -1,28 +0,0 @@
name: Build PR
on:
pull_request:
branches: ['main']
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['20']
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install packages
run: npm ci
- name: Run npm build
run: npm run build

View file

@ -3,11 +3,12 @@ import fs from 'fs';
import path from 'path'; import path from 'path';
let allPlugins = []; let allPlugins = [];
const isProd = process.env.ELEVENTY_ENV === "production";
const pathPrefix = isProd ? "/neoBeta/" : "/";
export default function (eleventyConfig) { export default function (eleventyConfig) {
eleventyConfig.setInputDirectory("src"); eleventyConfig.setInputDirectory("src");
eleventyConfig.setOutputDirectory("public"); eleventyConfig.setOutputDirectory("public");
eleventyConfig.addPassthroughCopy("src/projects/**/*.png"); eleventyConfig.addPassthroughCopy("src/projects/**/*.png");
eleventyConfig.addPassthroughCopy("src/projects/**/*.jpg"); eleventyConfig.addPassthroughCopy("src/projects/**/*.jpg");
eleventyConfig.addPassthroughCopy("src/projects/**/*.jpeg"); eleventyConfig.addPassthroughCopy("src/projects/**/*.jpeg");
@ -15,11 +16,13 @@ export default function (eleventyConfig) {
eleventyConfig.addPassthroughCopy("src/authors/**/*.jpg"); eleventyConfig.addPassthroughCopy("src/authors/**/*.jpg");
eleventyConfig.addPassthroughCopy("src/authors/**/*.jpeg"); eleventyConfig.addPassthroughCopy("src/authors/**/*.jpeg");
eleventyConfig.addPassthroughCopy("src/assets"); eleventyConfig.addPassthroughCopy("src/assets");
eleventyConfig.addPassthroughCopy({ "favicon/*" : "/" }); eleventyConfig.addPassthroughCopy({ "src/favicon/*" : "/" });
eleventyConfig.addCollection("projects", function(collection) { eleventyConfig.addCollection("projects", function(collection) {
return collection.getFilteredByGlob("src/projects/**/*.md"); return collection.getFilteredByGlob("src/projects/*/*.md");
}); });
eleventyConfig.addGlobalData("pathPrefix", pathPrefix)
eleventyConfig.addGlobalData("eleventyComputed", { eleventyConfig.addGlobalData("eleventyComputed", {
projectData: (data) => { projectData: (data) => {
@ -34,11 +37,14 @@ export default function (eleventyConfig) {
} }
return { name: path.basename(projectDir) }; return { name: path.basename(projectDir) };
}, },
layout: (data) => { layout: (data) => {
const inputPath = data.page.inputPath; const inputPath = data.page.inputPath;
if (inputPath.match(/\/projects\/[^\/]+\/docs\//)) return "docs.njk"; if (inputPath.match(/\/projects\/[^\/]+\/docs\//)) return "docs.njk";
return data.layout; return data.layout;
},
projectSlug: data => {
const url = data.page?.url || data.page?.filePathStem || "";
return url.replace(/\/$/,'').split('/').filter(Boolean).pop() || null;
} }
}); });
@ -70,4 +76,9 @@ export default function (eleventyConfig) {
fs.writeFileSync('./public/search_index.json', JSON.stringify(idx)); fs.writeFileSync('./public/search_index.json', JSON.stringify(idx));
}); });
return {
pathPrefix
}
}; };

View file

@ -2,7 +2,7 @@
layout: skeleton.njk layout: skeleton.njk
--- ---
<main> <main>
<p>You are seeing the documentation for: <a href="{{ projectData.url }}">{{ projectData.fileSlug }}</a></p> <p>You are seeing the documentation for: <span class="rainbowText">{{ projectData.fileSlug }}</span></p>
<hr> <hr>
<div> <div>
{{ content | safe }} {{ content | safe }}

View file

@ -6,12 +6,16 @@
{% if item.fileSlug == project %} {% if item.fileSlug == project %}
{% set projectData = item %} {% set projectData = item %}
<div class="featuredProject"> <div class="featuredProject">
<a href="/projects/{{ project }}"> <a href="{{ ('/projects/' + project) | url }}">
<img src="{% if projectData.data.logo %}/projects/{{project}}/{{ projectData.data.logo }}{% else %}/assets/mod-placeholder.png{% endif %}"> {% if projectData.data.logo %}
<img src="{{ ('/projects/' ~ project ~ '/' ~ projectData.data.logo) | url }}">
{% else %}
<img src="{{ '/assets/mod-placeholder.png' | url }}">
{% endif %}
</a> </a>
<div> <div>
<p class="featuredProjectName">{{ projectData.data.name }}</p> <p class="featuredProjectName">{{ projectData.data.name }}</p>
<p class="featuredProjectSubtitle">by <a href="/authors/{{ projectData.data.author }}/">{{ projectData.data.author }}</a></p> <p class="featuredProjectSubtitle">by <a href="{{ '/authors/' + projectData.data.author + '/' | url}}">{{ projectData.data.author }}</a></p>
<div class="featuredProjectSubtitle dimText">{{ projectData.data.subtitle }}</div> <div class="featuredProjectSubtitle dimText">{{ projectData.data.subtitle }}</div>
</div> </div>
</div> </div>

View file

@ -2,14 +2,14 @@
<div id="linksBox"> <div id="linksBox">
<div id="headerLinksAndTitle"> <div id="headerLinksAndTitle">
<div id="logoTitle"> <div id="logoTitle">
<img src="/assets/logo.png" id="logo"> <img src="{{ '/assets/logo.png' | url }}" id="logo">
<h1 id="title" class="rainbowText">neoBeta</h1> <h1 id="title" class="rainbowText">neoBeta</h1>
</div> </div>
<ul id="headerLinks"> <ul id="headerLinks">
<li><a href="/">home</a></li> <li><a href="{{ '/' | url }}">home</a></li>
<li><a href="/search">search</a></li> <li><a href="{{ '/search' | url }}">search</a></li>
<li><a href="/allprojects">index</a></li> <li><a href="{{ '/allprojects' | url}}">index</a></li>
<li><a href="/contribute">contribute</a></li> <li><a href="{{ '/contribute' | url}}">contribute</a></li>
</ul> </ul>
</div> </div>
<p id="credits">Adrian Victor, 2025 (<a href="https://git.disroot.org/adrianvictor/neoBeta">Unlicense</a>)</p> <p id="credits">Adrian Victor, 2025 (<a href="https://git.disroot.org/adrianvictor/neoBeta">Unlicense</a>)</p>

View file

@ -5,16 +5,16 @@ styles: ["project"]
<div id="project"> <div id="project">
<div id="projectHeader"> <div id="projectHeader">
{% if logo %} {% if logo %}
<img src="{{ page.dir }}{{ logo }}"> <img src="{{ ('/projects/' + projectSlug + '/' + logo) | url }}">
{% endif %} {% endif %}
<div id="projectTitleSubtitle"> <div id="projectTitleSubtitle">
<div id="projectTitleAuthor"> <div id="projectTitleAuthor">
<h1 id="projectTitle">{{ name }}</h1> <h1 id="projectTitle">{{ name }}</h1>
<p id="projectAuthor">by <a href="/authors/{{ author }}">{{ author }}</a></p> <p id="projectAuthor">by <a href="{{ ('/authors/' + author) | url }}">{{ author }}</a></p>
</div> </div>
<p id="projectSubtitle">{{ subtitle }}</p> <p id="projectSubtitle">{{ subtitle }}</p>
</div> </div>
<a id="downloadLink" href="{{ downloadLink }}"><button id="downloadButton">{% if downloadLink %}Download{% else %}Unavailable{% endif %}</button></a> <a id="downloadLink" href="{{ downloadLink | url}}"><button id="downloadButton">{% if downloadLink %}Download{% else %}Unavailable{% endif %}</button></a>
</div> </div>
{% if links or docs or images or releases %} {% if links or docs or images or releases %}
<div id="projectImagesAndInfo"> <div id="projectImagesAndInfo">
@ -25,7 +25,7 @@ styles: ["project"]
<p>{{ links | length }} links.</p> <p>{{ links | length }} links.</p>
<ul> <ul>
{% for label, addr in links %} {% for label, addr in links %}
<li><a href="{{ addr }}">{{ label }}</a></li> <li><a href="{{ addr | url}}">{{ label }}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}
@ -33,7 +33,7 @@ styles: ["project"]
<p>{{ docs | length }} documentaion files.</p> <p>{{ docs | length }} documentaion files.</p>
<ul> <ul>
{% for label, addr in docs %} {% for label, addr in docs %}
<li><a href="{{ addr }}">{{ label }}</a></li> <li><a href="{{ addr | url }}">{{ label }}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}

View file

@ -3,7 +3,10 @@
<p>Images</p> <p>Images</p>
<div id="projectCarrouselImageHolder"> <div id="projectCarrouselImageHolder">
{% for image in images %} {% for image in images %}
<a href="{{ page.dir }}{{ image }}"><img class="projectImage" src="{{ page.dir }}{{ image }}" alt=""></a> {% set dir = (page.filePathStem | default(page.url) ) | replace('/index','') %}
<a href="{{ (dir ~ '/' ~ image) | url }}">
<img class="projectImage" src="{{ (dir ~ '/' ~ image) | url }}">
</a>
{% endfor %} {% endfor %}
</div> </div>
</div> </div>

View file

@ -2,14 +2,17 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<link rel="stylesheet" href="/assets/stylesheets/styles.css" media="screen"> <link rel="stylesheet" href="{{ '/assets/stylesheets/styles.css' | url }}" media="screen">
{% for stylesheet in styles %} {% for stylesheet in styles %}
<link rel="stylesheet" href="/assets/stylesheets/{{ stylesheet }}.css"> <link rel="stylesheet" href="{{ ('/assets/stylesheets/' + stylesheet + '.css') | url }}">
{% endfor %} {% endfor %}
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% if name %}{{ name }} - {% endif %}neoBeta</title> <title>{% if name %}{{ name }} - {% endif %}neoBeta</title>
</head> </head>
<body> <body>
<script>
window.ELEVENTY_PATH_PREFIX = "{{ pathPrefix | safe }}";
</script>
<div id="everythingHelper"> <div id="everythingHelper">
<aside> <aside>
{% include "header.njk" %} {% include "header.njk" %}

View file

@ -6,16 +6,18 @@ pagination:
alias: paginatedProjects alias: paginatedProjects
styles: ["search"] styles: ["search"]
--- ---
<h1>Projects Index - page {{ pagination.pageNumber + 1 }}</h1>
<ul style="display: flex; flex-direction: column; gap: 1em;"> <ul style="display: flex; flex-direction: column; gap: 1em;">
{% for project in paginatedProjects %} {% for project in paginatedProjects %}
<div class="searchItem"> <div class="searchItem">
<p> <p>
{% if project.data.logo %} {% if project.data.logo %}
<img float="left" class="searchItemImage" src="{{ project.url }}{{ project.data.logo }}"> <img float="left" class="searchItemImage" src="{{ (project.url + project.data.logo) | url }}">
{% endif %} {% endif %}
<a class="searchItemTitle" href="{{ project.url }}">{{ project.data.name }}</a> <a class="searchItemTitle" href="{{ project.url | url }}">{{ project.data.name }}</a>
{% if project.data.author %} {% if project.data.author %}
by <a href="/authors/{{ project.data.author }}">{{ project.data.author }}</a> by <a href="{{ ('/authors/' + project.data.author) | url }}">{{ project.data.author }}</a>
{% endif %} {% endif %}
</p> </p>
<p class="searchItemDescription">{{ project.data.subtitle }}</p> <p class="searchItemDescription">{{ project.data.subtitle }}</p>
@ -30,9 +32,9 @@ styles: ["search"]
<nav> <nav>
{% if pagination.href.previous %} {% if pagination.href.previous %}
<a href="{{ pagination.href.previous }}">Prev</a> <a href="{{ pagination.href.previous | url }}">Prev</a>
{% endif %} {% endif %}
{% if pagination.href.next %} {% if pagination.href.next %}
<a href="{{ pagination.href.next }}">Next</a> <a href="{{ pagination.href.next | url }}">Next</a>
{% endif %} {% endif %}
</nav> </nav>

View file

@ -1,4 +1,9 @@
fetch('/search_index.json') function url(path) {
const prefix = (window.ELEVENTY_PATH_PREFIX || '').replace(/\/$/,'');
return (prefix ? prefix + '/' : '/') + path.replace(/^\/+/,'');
}
fetch(url("search_index.json"))
.then(r => r.json()) .then(r => r.json())
.then(data => { .then(data => {
const idx = elasticlunr.Index.load(data); const idx = elasticlunr.Index.load(data);
@ -28,7 +33,7 @@ fetch('/search_index.json')
}); });
return `<div class="searchItem"> return `<div class="searchItem">
<p>${doc.image ? `<img float=left class="searchItemImage" src="${doc.image}">` : ''} <a class="searchItemTitle" href="${doc.url}">${doc.title}</a>${doc.author ? ` by <a href="/authors/${doc.author}">${doc.author}</a>` : ''}</p> <p>${doc.image ? `<img float=left class="searchItemImage" src="${url(doc.image)}">` : ''} <a class="searchItemTitle" href="${url(doc.url)}">${doc.title}</a>${doc.author ? ` by <a href="${ url('/authors/' + doc.author) }">${doc.author}</a>` : ''}</p>
<p class="searchItemDescription">${doc.subtitle}</p> <p class="searchItemDescription">${doc.subtitle}</p>
<div class="searchItemTagHolder"> <div class="searchItemTagHolder">
${tagsHTML} ${tagsHTML}

View file

@ -15,7 +15,7 @@
@font-face { @font-face {
font-family: Minecraft; font-family: Minecraft;
src: url("/assets/MinecraftRegular-Bmg3.otf") format("opentype"); src: url("../MinecraftRegular-Bmg3.otf") format("opentype");
} }
body { body {

View file

@ -10,22 +10,15 @@ neoBeta is an open-source content management system. There are various ways you
### Required metadata fields ### Required metadata fields
- *name* - project name. - *name* - project name.
```"name": "Ghosts 'n Stuff"```
- *subtitle* - project's brief description. - *subtitle* - project's brief description.
```"subtitle": "Miscellaneous additions to your server."```
- *author* - your author name, must be consistent across all your submissions. - *author* - your author name, must be consistent across all your submissions.
```"author": "tenkuma"```
- *tags* - whether your project is a plugin or mod. - *tags* - whether your project is a plugin or mod.
```"tags": ["plugin", "mod"]```
### Optional metadata fields ### Optional metadata fields
Please fill as many fields as possible. Please fill as many fields as possible.
- *downloadLink* - link for when you click the download link. - *downloadLink* - link for when you click the download link.
```"downloadLink": "https://example.com"```
- *images* - lists of image files names or URLs that will appear in the project page. - *images* - lists of image files names or URLs that will appear in the project page.
```"images": "["image1.png", "image2.png", "image3.png"]"```
- *logo* - your logo file name or URL. - *logo* - your logo file name or URL.
```"logo": "logo.png"```
### Config file example ### Config file example
``` ```

View file

@ -3,7 +3,7 @@ styles: ["search"]
layout: "base.njk" layout: "base.njk"
--- ---
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/elasticlunr/0.9.6/elasticlunr.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/elasticlunr/0.9.6/elasticlunr.min.js"></script>
<script src="/assets/search.js" defer></script> <script src="{{ '/assets/search.js' | url }}" defer></script>
<style> <style>
main { main {