[SiteGen] Add meta

This commit is contained in:
Ducko 2021-07-02 17:18:08 +01:00 committed by Alyxia Sother
parent 758810cfe8
commit cf61e63df0
No known key found for this signature in database
GPG Key ID: 355968D14144B739
2 changed files with 22 additions and 6 deletions

View File

@ -1,5 +1,4 @@
import { readFileSync, writeFileSync, copyFileSync } from "fs"; import { readFileSync, writeFileSync, copyFileSync } from "fs";
import { dirname, join } from 'path'; import { dirname, join } from 'path';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
@ -55,19 +54,28 @@ export default () => {
let cards = []; let cards = [];
let name = 'GooseMod Store';
let description = 'Browse GooseMod modules';
for (const repo of repos) { for (const repo of repos) {
const repoName = repo.split('/').pop().split('.')[0]; console.log(repo);
console.log(repo, repoName);
const json = JSON.parse(readFileSync(repo, 'utf8')); const json = JSON.parse(readFileSync(repo, 'utf8'));
console.log(json);
if (repos.length === 1) { // 1 repo likely means a custom repo, so use that name and description
name = json.meta.name;
description = json.meta.description;
}
cards = cards.concat(json.modules); cards = cards.concat(json.modules);
} }
cards = cards.sort((a, b) => a.name.localeCompare(b.name)).map((x) => makeCard(x)); cards = cards.sort((a, b) => a.name.localeCompare(b.name)).map((x) => makeCard(x));
template = template.replace('ALL_CARDS', cards.join('\n')); template = template
.replace('ALL_CARDS', cards.join('\n'))
.replaceAll('NAME', name)
.replaceAll('DESCRIPTION', description);
writeFileSync(join(global.distDir, 'index.html'), template); writeFileSync(join(global.distDir, 'index.html'), template);

View File

@ -1,10 +1,18 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<title>GooseMod Store</title> <title>NAME</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/> <meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta itemprop="name" content="NAME">
<meta itemprop="description" content="DESCRIPTION">
<meta property="og:title" content="NAME">
<meta property="og:description" content="DESCRIPTION">
<meta property="og:type" content="website">
<meta property="og:url" content="/">
<style> <style>
:root { :root {
--elevation-medium: 0 4px 4px rgba(0,0,0,0.16); --elevation-medium: 0 4px 4px rgba(0,0,0,0.16);