Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds setting for site main language #473

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const DEFAULT_SETTINGS: DigitalGardenSettings = {
faviconPath: "",
noteSettingsIsInitialized: false,
siteName: "Digital Garden",
mainLanguage: "en",
slugifyEnabled: true,
// Note Icon Related Settings
noteIconKey: "dg-note-icon",
Expand Down
1 change: 1 addition & 0 deletions scripts/generateGardenSettings.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const gardenSettings = {
faviconPath: "",
noteSettingsIsInitialized: true,
siteName: "Digital Garden",
mainLanguage: "en",
slugifyEnabled: true,
noteIconKey: "dg-note-icon",
defaultNoteIcon: "",
Expand Down
1 change: 1 addition & 0 deletions src/models/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default interface DigitalGardenSettings {
theme: string;
baseTheme: string;
faviconPath: string;
mainLanguage: string;

siteName: string;

Expand Down
2 changes: 2 additions & 0 deletions src/repositoryConnection/DigitalGardenSiteManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default class DigitalGardenSiteManager {
const theme = JSON.parse(this.settings.theme);
const baseTheme = this.settings.baseTheme;
const siteName = this.settings.siteName;
const mainLanguage = this.settings.mainLanguage;
let gardenBaseUrl = "";

// check that gardenbaseurl is not an access token wrongly pasted.
Expand All @@ -84,6 +85,7 @@ export default class DigitalGardenSiteManager {

const envValues = {
SITE_NAME_HEADER: siteName,
SITE_MAIN_LANGUAGE: mainLanguage,
SITE_BASE_URL: gardenBaseUrl,
SHOW_CREATED_TIMESTAMP: this.settings.showCreatedTimestamp,
TIMESTAMP_FORMAT: this.settings.timestampFormat,
Expand Down
14 changes: 14 additions & 0 deletions src/views/SettingsView/SettingView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,20 @@ export default class SettingView {
}),
);

new Setting(themeModal.contentEl)
.setName("Main language")
.setDesc(
'ISO 639-1 language code for the main language of your site. This is used to set correct <html lang="">.',
)
.addText((text) =>
text
.setValue(this.settings.mainLanguage)
.onChange(async (value) => {
this.settings.mainLanguage = value;
await this.saveSettings();
}),
);

new Setting(themeModal.contentEl)
.setName("Favicon")
.setDesc(
Expand Down