mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-31 18:18:36 +08:00
complete the basic notionnext function
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { App, Notice, TFile } from "obsidian";
|
||||
import ObsidianSyncNotionPlugin from "../main";
|
||||
import { PluginSettings } from "../ui/settingTabs";
|
||||
import {DatabaseDetails, PluginSettings} from "../ui/settingTabs";
|
||||
|
||||
export async function updateYamlInfo(
|
||||
yamlContent: string,
|
||||
@@ -8,10 +8,14 @@ export async function updateYamlInfo(
|
||||
res: any,
|
||||
app: App,
|
||||
plugin: ObsidianSyncNotionPlugin,
|
||||
dbDetails: DatabaseDetails,
|
||||
) {
|
||||
let { url, id } = res.json
|
||||
// replace www to notionID
|
||||
const { notionUser } = plugin.settings;
|
||||
const { abName } = dbDetails
|
||||
const notionIDKey = `NotionID-${abName}`;
|
||||
const linkKey = `link-${abName}`;
|
||||
|
||||
if (notionUser !== "") {
|
||||
// replace url str "www" to notionID
|
||||
@@ -19,15 +23,15 @@ export async function updateYamlInfo(
|
||||
}
|
||||
|
||||
await app.fileManager.processFrontMatter(nowFile, yamlContent => {
|
||||
if (yamlContent['notionID']) {
|
||||
delete yamlContent['notionID']
|
||||
if (yamlContent[notionIDKey]) {
|
||||
delete yamlContent[notionIDKey]
|
||||
}
|
||||
if (yamlContent['link']) {
|
||||
delete yamlContent['link']
|
||||
if (yamlContent[linkKey]) {
|
||||
delete yamlContent[linkKey]
|
||||
}
|
||||
// add new notionID and link
|
||||
yamlContent.notionID = id;
|
||||
yamlContent.link = url;
|
||||
yamlContent[notionIDKey] = id;
|
||||
yamlContent[linkKey] = url;
|
||||
});
|
||||
|
||||
try {
|
||||
|
||||
@@ -57,7 +57,7 @@ export async function uploadCommandGeneral(
|
||||
app: App,
|
||||
) {
|
||||
|
||||
const { notionAPI, databaseID } = settings;
|
||||
const { notionAPI, databaseID } = dbDetails;
|
||||
|
||||
// Check if the user has set up the Notion API and database ID
|
||||
if (notionAPI === "" || databaseID === "") {
|
||||
|
||||
@@ -15,6 +15,7 @@ export class Upload2NotionNext extends UploadBaseNext {
|
||||
|
||||
constructor(plugin: MyPlugin, dbDetails: DatabaseDetails) {
|
||||
super(plugin);
|
||||
this.dbDetails = dbDetails
|
||||
}
|
||||
|
||||
// 因为需要解析notion的block进行对比,非常的麻烦,
|
||||
@@ -280,7 +281,7 @@ export class Upload2NotionNext extends UploadBaseNext {
|
||||
);
|
||||
}
|
||||
if (res.status === 200) {
|
||||
await updateYamlInfo(markdown, nowFile, res, app, this.plugin)
|
||||
await updateYamlInfo(markdown, nowFile, res, app, this.plugin, this.dbDetails)
|
||||
} else {
|
||||
new Notice(`${res.text}`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user