miom.space/_config.ts

62 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-02-26 17:32:30 +00:00
import lume from "lume/mod.ts";
2024-02-24 12:45:21 +00:00
import inline from "lume/plugins/inline.ts";
2023-02-26 17:32:30 +00:00
import postcss from "lume/plugins/postcss.ts";
2021-10-22 11:13:16 +00:00
2022-03-31 18:11:56 +00:00
const markdown = { options: { breaks: true } };
2021-10-22 11:13:16 +00:00
const site = lume({}, { markdown });
2024-02-24 12:45:21 +00:00
site.use(inline());
const languages = [
{
name: 'deutsch',
slug: 'de',
urlPrefix: '',
},
{
name: 'english',
slug: 'en',
urlPrefix: 'en',
}
]
site.data('languages', languages);
site.preprocess([ '.md' ], (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}`), '');
}
2024-02-24 12:45:21 +00:00
});
2021-10-22 11:13:16 +00:00
site.use(postcss());
site.loadAssets([ ".js" ]);
2021-10-22 11:13:16 +00:00
site.copy("fonts");
site.copy("img");
2024-04-14 13:48:12 +00:00
site.copy("favicon.ico");
2021-10-22 11:13:16 +00:00
site.filter("title", (value = '') => value + (value ? " | " : "") + "MiOM");
2021-10-22 21:42:44 +00:00
2024-02-24 12:45:21 +00:00
site.ignore(
".direnv",
"README.md",
"CHANGELOG.md",
"LICENSE.md",
"docker-compose.yml",
);
2021-10-22 11:13:16 +00:00
export default site;