Skip to content

Commit b462b6c

Browse files
authored
Merge pull request #252 from nullstack/fix/blog-engine
🐛 fix build
2 parents 5232e4e + 9b44b88 commit b462b6c

File tree

4 files changed

+77
-259
lines changed

4 files changed

+77
-259
lines changed

i18n/en-US/components/Post.yml

Whitespace-only changes.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "ISC",
77
"devDependencies": {
88
"concurrently": "^7.2.0",
9-
"nullstack": "~0.16.0",
9+
"nullstack": "~0.17.2",
1010
"tailwindcss": "^3.0.0"
1111
},
1212
"scripts": {

src/Translatable.njs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
import { readFileSync } from 'fs';
2-
import Nullstack from 'nullstack';
3-
import YAML from 'yaml';
1+
import { existsSync, readFileSync } from "fs";
2+
import Nullstack from "nullstack";
3+
import YAML from "yaml";
44

55
class Translatable extends Nullstack {
6-
76
static async geti18nByLocale({ locale }) {
8-
const [name] = this.name.split('_');
9-
const file = readFileSync(`i18n/${locale}/components/${name}.yml`, 'utf-8');
10-
return YAML.parse(file);
7+
const [name] = this.name.split("_");
8+
const translationPath = `i18n/${locale}/components/${name}.yml`;
9+
if (existsSync(translationPath)) {
10+
const file = readFileSync(translationPath, "utf-8");
11+
return YAML.parse(file);
12+
}
13+
return {};
1114
}
1215

1316
async initiate({ page, locale }) {
1417
this.locale = locale;
1518
this.i18n = await this.geti18nByLocale({ locale });
1619
if (this.i18n.title) {
1720
page.description = this.i18n.description;
18-
page.locale = locale || 'en-US';
21+
page.locale = locale || "en-US";
1922
}
2023
}
2124

@@ -30,7 +33,6 @@ class Translatable extends Nullstack {
3033
this.initiate();
3134
}
3235
}
33-
3436
}
3537

36-
export default Translatable;
38+
export default Translatable;

0 commit comments

Comments
 (0)