35 lines
910 B
JavaScript
35 lines
910 B
JavaScript
import { queryNotionDataSource } from "../utils/notion.js";
|
|
import {
|
|
transformThemes,
|
|
transformRedirectsData,
|
|
transformGlobalThemesData,
|
|
storeSettings,
|
|
} from "../utils/settings.js";
|
|
|
|
export async function importNotionSettings(env) {
|
|
console.log("Importing settings from Notion...");
|
|
const [globalThemesData, themesData, redirectsData] = await Promise.all([
|
|
queryNotionDataSource(env.GLOBAL_THEMES_DB),
|
|
queryNotionDataSource(env.THEMES_DB),
|
|
queryNotionDataSource(env.REDIRECTS_DB),
|
|
]);
|
|
|
|
console.log("Fetched settings from Notion.");
|
|
|
|
const themes = await transformThemes(themesData);
|
|
const globalThemes = transformGlobalThemesData(env, globalThemesData, themes);
|
|
const redirects = await transformRedirectsData(env, redirectsData);
|
|
|
|
await storeSettings(env, {
|
|
globalThemes,
|
|
themes,
|
|
redirects,
|
|
});
|
|
|
|
return {
|
|
globalThemes,
|
|
themes,
|
|
redirects,
|
|
};
|
|
}
|