From fbf0d7bcf3290c207aec53f091f7933c29c7233e Mon Sep 17 00:00:00 2001 From: sunwei Date: Tue, 7 Jan 2025 19:47:33 +0800 Subject: [PATCH] support GA and default language --- manifest.json | 2 +- package.json | 2 +- src/fileinfo.ts | 22 ++++++++++++++++++++-- src/frontmatter.ts | 5 +++++ src/hugoverse.ts | 2 ++ versions.json | 3 ++- 6 files changed, 31 insertions(+), 5 deletions(-) diff --git a/manifest.json b/manifest.json index b2b8056..eb9ca92 100644 --- a/manifest.json +++ b/manifest.json @@ -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", diff --git a/package.json b/package.json index 913328e..52de703 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/fileinfo.ts b/src/fileinfo.ts index d189b9d..380f0a4 100644 --- a/src/fileinfo.ts +++ b/src/fileinfo.ts @@ -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"; @@ -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) { diff --git a/src/frontmatter.ts b/src/frontmatter.ts index e55def1..910315e 100644 --- a/src/frontmatter.ts +++ b/src/frontmatter.ts @@ -5,6 +5,9 @@ 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 = [ '---', @@ -12,6 +15,8 @@ const basicFrontMatter = [ '', `${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' diff --git a/src/hugoverse.ts b/src/hugoverse.ts index 10e09b3..4cd7d91 100644 --- a/src/hugoverse.ts +++ b/src/hugoverse.ts @@ -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); diff --git a/versions.json b/versions.json index ada3b66..933edf6 100644 --- a/versions.json +++ b/versions.json @@ -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" } \ No newline at end of file