pub.solar/_config.ts

63 lines
1.4 KiB
TypeScript

import lume from "lume/mod.ts";
import sass from "lume/plugins/sass.ts";
import date from "lume/plugins/date.ts";
import jsx from "lume/plugins/jsx.ts";
import terser from "lume/plugins/terser.ts";
import postcss from "lume/plugins/postcss.ts";
const site = lume();
const languages = [
{
name: 'deutsch',
slug: 'de',
urlPrefix: 'de',
},
{
name: 'english',
slug: 'en',
urlPrefix: '',
},
];
site.data('languages', languages);
site.preprocess([ '.yml' ], (pages) => {
for (const page of pages) {
const urlParts = (page.data.url || '').replace(/^\/|\/$/g, '').split('/');
const langPrefix = urlParts[0];
const currentLang = (() => {
if (langPrefix.length === 2) {
return languages.find(lang => lang.urlPrefix === langPrefix);
}
return languages.find(lang => lang.urlPrefix.length === 0);
})() || languages[0];
page.data.language = currentLang;
page.data.otherLang = languages.find(l => l.slug !== currentLang.slug);
page.data.baseURL = page.data.url.replace(new RegExp(`^\\/${currentLang.slug}`), '');
}
});
site.use(sass());
site.use(date());
site.use(jsx());
site.use(terser());
site.use(postcss());
site.loadAssets([ ".js" ]);
site.copy("assets");
site.copy("fonts");
site.ignore(
".direnv",
"README.md",
"CHANGELOG.md",
"LICENSE.md",
"docker-compose.yml",
);
export default site;