pub.solar/_config.ts

63 lines
1.4 KiB
TypeScript
Raw Normal View History

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";
2022-10-02 18:46:42 +00:00
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());
2022-10-02 18:46:42 +00:00
site.use(date());
site.use(jsx());
site.use(terser());
site.use(postcss());
site.loadAssets([ ".js" ]);
site.copy("assets");
site.copy("fonts");
2022-10-02 18:46:42 +00:00
site.ignore(
".direnv",
"README.md",
"CHANGELOG.md",
"LICENSE.md",
"docker-compose.yml",
);
2022-10-02 18:46:42 +00:00
export default site;