Skip to content

Commit

Permalink
support GA and default language
Browse files Browse the repository at this point in the history
  • Loading branch information
sunwei committed Jan 7, 2025
1 parent d928f11 commit fbf0d7b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 5 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "mdfriday",
"name": "Friday",
"version": "0.2.2",
"version": "0.2.3",
"minAppVersion": "0.15.0",
"description": "Notes to Website. Friday helps you turn Markdown documents into websites in minutes.",
"author": "sunwei",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-friday-plugin",
"version": "0.2.2",
"version": "0.2.3",
"description": "Friday is an Obsidian plugin that empowers users to focus on content creation by writing Markdown files, while we handle the distribution. From creating websites to content deployment, Friday serves as a creative output assistant, helping users turn their work into publishable sites with ease.",
"main": "main.js",
"scripts": {
Expand Down
22 changes: 20 additions & 2 deletions src/fileinfo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import {App, Notice, TFolder} from "obsidian";
import {FM_CONTENT, FM_CONTENT_EMPTY, FM_FRIDAY_PLUGIN, FM_MENU, FM_SITE_ID, FM_THEME} from "./frontmatter";
import {
FM_CONTENT,
FM_CONTENT_EMPTY,
FM_DEFAULT_LANGUAGE,
FM_FRIDAY_PLUGIN, FM_GA,
FM_MENU,
FM_SITE_ID,
FM_THEME
} from "./frontmatter";
import * as path from "path";
import * as yaml from "js-yaml";
import {IsLanguageSupported, IsRtlLanguage} from "./language";
Expand Down Expand Up @@ -125,8 +133,18 @@ export class FileInfo {
return path.basename(this.getThemeName())
}

getDefaultLanguage(): string {
return this.frontMatter?.[FM_DEFAULT_LANGUAGE] ?? ''
}

getGA(): string {
return this.frontMatter?.[FM_GA] ?? ''
}

getParams(): string {
const excludeKeys = [FM_FRIDAY_PLUGIN, FM_SITE_ID, FM_CONTENT, FM_THEME, FM_MENU];
const excludeKeys = [
FM_FRIDAY_PLUGIN, FM_SITE_ID, FM_CONTENT, FM_THEME,
FM_MENU, FM_DEFAULT_LANGUAGE, FM_GA];

const paramsArray = [];
for (const key in this.frontMatter) {
Expand Down
5 changes: 5 additions & 0 deletions src/frontmatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ export const FM_CONTENT_EMPTY = 'empty';
export const FM_THEME = 'theme';
export const FM_DEFAULT_THEME = 'github.com/mdfriday/theme-long-teng';
export const FM_MENU = 'menu';
export const FM_DEFAULT_LANGUAGE = 'defaultLanguage';
export const FM_GA = 'ga';
export const FM_EMPTY_GA = 'GT-XXXXXXXXX';

const basicFrontMatter = [
'---',
'', `${FM_FRIDAY_PLUGIN}: enabled`, '',
'', `${FM_SITE_ID}: '0'`, '',
'', `${FM_THEME}: ${FM_DEFAULT_THEME}`, '',
'', `${FM_CONTENT}: ${FM_CONTENT_EMPTY}`, '',
'', `${FM_DEFAULT_LANGUAGE}: en`, '',
'', `${FM_GA}: ${FM_EMPTY_GA}`, '',
'---',
'', ''].join(
'\n'
Expand Down
2 changes: 2 additions & 0 deletions src/hugoverse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ export class Hugoverse {
body.append("owner", this.plugin.user.getName());
body.append("Params", this.plugin.fileInfo.getParams());
body.append("working_dir", "");
body.append("default_content_language", this.plugin.fileInfo.getDefaultLanguage());
body.append("google_analytics", this.plugin.fileInfo.getGA());

this.plugin.fileInfo.languages.forEach((lang, index) => {
body.append(`languages.${index}`, lang);
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"0.1.8": "0.15.0",
"0.2.0": "0.15.0",
"0.2.1": "0.15.0",
"0.2.2": "0.15.0"
"0.2.2": "0.15.0",
"0.2.3": "0.15.0"
}

0 comments on commit fbf0d7b

Please sign in to comment.