Skip to content

Commit

Permalink
Adds setting for site main language
Browse files Browse the repository at this point in the history
Adds a setting for the site main language. This setting is used to set
the the `lang` attribute of the html element. This improves
accessibility and assists search engines and browsers.

Reference: https://www.w3schools.com/tags/ref_language_codes.asp
  • Loading branch information
stalegjelsten authored and oleeskild committed Oct 16, 2023
1 parent 6aad9b6 commit b0982b5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
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

0 comments on commit b0982b5

Please sign in to comment.