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';
let allPlugins = [];
const isProd = process.env.ELEVENTY_ENV === "production";
const pathPrefix = isProd ? "/neoBeta/" : "/";
export default function (eleventyConfig) {
eleventyConfig.setInputDirectory("src");
eleventyConfig.setOutputDirectory("public");
eleventyConfig.addPassthroughCopy("src/projects/**/*.png");
eleventyConfig.addPassthroughCopy("src/projects/**/*.jpg");
eleventyConfig.addPassthroughCopy("src/projects/**/*.jpeg");
@ -15,12 +16,14 @@ export default function (eleventyConfig) {
eleventyConfig.addPassthroughCopy("src/authors/**/*.jpg");
eleventyConfig.addPassthroughCopy("src/authors/**/*.jpeg");
eleventyConfig.addPassthroughCopy("src/assets");
eleventyConfig.addPassthroughCopy({ "favicon/*" : "/" });
eleventyConfig.addPassthroughCopy({ "src/favicon/*" : "/" });
eleventyConfig.addCollection("projects", function(collection) {
return collection.getFilteredByGlob("src/projects/**/*.md");
return collection.getFilteredByGlob("src/projects/*/*.md");
});
eleventyConfig.addGlobalData("pathPrefix", pathPrefix)
eleventyConfig.addGlobalData("eleventyComputed", {
projectData: (data) => {
const inputPath = data.page.inputPath;
@ -34,11 +37,14 @@ export default function (eleventyConfig) {
}
return { name: path.basename(projectDir) };
},
layout: (data) => {
const inputPath = data.page.inputPath;
if (inputPath.match(/\/projects\/[^\/]+\/docs\//)) return "docs.njk";
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));
});
return {
pathPrefix
}
};

View file

@ -2,7 +2,7 @@
layout: skeleton.njk
---
<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>
<div>
{{ content | safe }}

View file

@ -6,12 +6,16 @@
{% if item.fileSlug == project %}
{% set projectData = item %}
<div class="featuredProject">
<a href="/projects/{{ project }}">
<img src="{% if projectData.data.logo %}/projects/{{project}}/{{ projectData.data.logo }}{% else %}/assets/mod-placeholder.png{% endif %}">
<a href="{{ ('/projects/' + project) | url }}">
{% if projectData.data.logo %}
<img src="{{ ('/projects/' ~ project ~ '/' ~ projectData.data.logo) | url }}">
{% else %}
<img src="{{ '/assets/mod-placeholder.png' | url }}">
{% endif %}
</a>
<div>
<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>
</div>

View file

@ -2,14 +2,14 @@
<div id="linksBox">
<div id="headerLinksAndTitle">
<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>
</div>
<ul id="headerLinks">
<li><a href="/">home</a></li>
<li><a href="/search">search</a></li>
<li><a href="/allprojects">index</a></li>
<li><a href="/contribute">contribute</a></li>
<li><a href="{{ '/' | url }}">home</a></li>
<li><a href="{{ '/search' | url }}">search</a></li>
<li><a href="{{ '/allprojects' | url}}">index</a></li>
<li><a href="{{ '/contribute' | url}}">contribute</a></li>
</ul>
</div>
<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="projectHeader">
{% if logo %}
<img src="{{ page.dir }}{{ logo }}">
<img src="{{ ('/projects/' + projectSlug + '/' + logo) | url }}">
{% endif %}
<div id="projectTitleSubtitle">
<div id="projectTitleAuthor">
<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>
<p id="projectSubtitle">{{ subtitle }}</p>
</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>
{% if links or docs or images or releases %}
<div id="projectImagesAndInfo">
@ -25,7 +25,7 @@ styles: ["project"]
<p>{{ links | length }} links.</p>
<ul>
{% for label, addr in links %}
<li><a href="{{ addr }}">{{ label }}</a></li>
<li><a href="{{ addr | url}}">{{ label }}</a></li>
{% endfor %}
</ul>
{% endif %}
@ -33,7 +33,7 @@ styles: ["project"]
<p>{{ docs | length }} documentaion files.</p>
<ul>
{% for label, addr in docs %}
<li><a href="{{ addr }}">{{ label }}</a></li>
<li><a href="{{ addr | url }}">{{ label }}</a></li>
{% endfor %}
</ul>
{% endif %}

View file

@ -3,7 +3,10 @@
<p>Images</p>
<div id="projectCarrouselImageHolder">
{% 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 %}
</div>
</div>

View file

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

View file

@ -6,16 +6,18 @@ pagination:
alias: paginatedProjects
styles: ["search"]
---
<h1>Projects Index - page {{ pagination.pageNumber + 1 }}</h1>
<ul style="display: flex; flex-direction: column; gap: 1em;">
{% for project in paginatedProjects %}
<div class="searchItem">
<p>
{% 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 %}
<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 %}
by <a href="/authors/{{ project.data.author }}">{{ project.data.author }}</a>
by <a href="{{ ('/authors/' + project.data.author) | url }}">{{ project.data.author }}</a>
{% endif %}
</p>
<p class="searchItemDescription">{{ project.data.subtitle }}</p>
@ -30,9 +32,9 @@ styles: ["search"]
<nav>
{% if pagination.href.previous %}
<a href="{{ pagination.href.previous }}">Prev</a>
<a href="{{ pagination.href.previous | url }}">Prev</a>
{% endif %}
{% if pagination.href.next %}
<a href="{{ pagination.href.next }}">Next</a>
<a href="{{ pagination.href.next | url }}">Next</a>
{% endif %}
</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(data => {
const idx = elasticlunr.Index.load(data);
@ -28,7 +33,7 @@ fetch('/search_index.json')
});
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>
<div class="searchItemTagHolder">
${tagsHTML}

View file

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

View file

@ -10,22 +10,15 @@ neoBeta is an open-source content management system. There are various ways you
### Required metadata fields
- *name* - project name.
```"name": "Ghosts 'n Stuff"```
- *subtitle* - project's brief description.
```"subtitle": "Miscellaneous additions to your server."```
- *author* - your author name, must be consistent across all your submissions.
```"author": "tenkuma"```
- *tags* - whether your project is a plugin or mod.
```"tags": ["plugin", "mod"]```
### Optional metadata fields
Please fill as many fields as possible.
- *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": "["image1.png", "image2.png", "image3.png"]"```
- *logo* - your logo file name or URL.
```"logo": "logo.png"```
### Config file example
```

View file

@ -3,7 +3,7 @@ styles: ["search"]
layout: "base.njk"
---
<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>
main {