Compare commits
No commits in common. "f39c8c19818f2af6281bcf5ab93e0e16f8409929" and "d85111c86344c95f92c56e378e6154b348023f03" have entirely different histories.
f39c8c1981
...
d85111c863
7
Jenkinsfile
vendored
7
Jenkinsfile
vendored
@ -2,13 +2,6 @@ def deploy() {
|
|||||||
node('ubuntu') {
|
node('ubuntu') {
|
||||||
try {
|
try {
|
||||||
checkout scm
|
checkout scm
|
||||||
|
|
||||||
// Only deploy from main branch
|
|
||||||
def branch = env.BRANCH_NAME ?: sh(script: 'git rev-parse --abbrev-ref HEAD', returnStdout: true).trim()
|
|
||||||
if (branch != 'main') {
|
|
||||||
echo "Skipping deployment: not on main branch (current branch: ${branch})"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nodejs(nodeJSInstallationName: 'Node23') {
|
nodejs(nodeJSInstallationName: 'Node23') {
|
||||||
stage('Install') {
|
stage('Install') {
|
||||||
|
|||||||
@ -2,7 +2,6 @@ import { queryNotionDataSource, getNotionPage } from "../utils/notion.js";
|
|||||||
import { transformPageData, storePages, getPages } from "../utils/pages.js";
|
import { transformPageData, storePages, getPages } from "../utils/pages.js";
|
||||||
import { getProperties } from "../utils/properties.js";
|
import { getProperties } from "../utils/properties.js";
|
||||||
import { getSettings } from "../utils/settings.js";
|
import { getSettings } from "../utils/settings.js";
|
||||||
import { unionBy } from "lodash";
|
|
||||||
|
|
||||||
// Fetch Notion pages (raw data)
|
// Fetch Notion pages (raw data)
|
||||||
export async function importNotionPages(env, notionId = null) {
|
export async function importNotionPages(env, notionId = null) {
|
||||||
@ -30,10 +29,22 @@ export async function importNotionPages(env, notionId = null) {
|
|||||||
const cachedPages = await getPages(env);
|
const cachedPages = await getPages(env);
|
||||||
console.log("Cached pages:", cachedPages);
|
console.log("Cached pages:", cachedPages);
|
||||||
console.log("Pages:", pages);
|
console.log("Pages:", pages);
|
||||||
// Use unionBy to merge pages by notionId (new pages take precedence)
|
// Create a map of new pages by notionId for quick lookup
|
||||||
const mergedPages = unionBy(pages, cachedPages, "notionId");
|
const newPagesMap = new Map(pages.map((page) => [page.notionId, page]));
|
||||||
// Sort by order
|
|
||||||
mergedPages.sort((a, b) => (a.order || 0) - (b.order || 0));
|
// Merge: preserve cached order, but replace with new data if available
|
||||||
|
const mergedPages = cachedPages.map((cachedPage) => {
|
||||||
|
return newPagesMap.has(cachedPage.notionId)
|
||||||
|
? newPagesMap.get(cachedPage.notionId)
|
||||||
|
: cachedPage;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add any new pages that weren't in cache
|
||||||
|
const existingNotionIds = new Set(cachedPages.map((page) => page.notionId));
|
||||||
|
const newPages = pages.filter(
|
||||||
|
(page) => !existingNotionIds.has(page.notionId)
|
||||||
|
);
|
||||||
|
mergedPages.push(...newPages);
|
||||||
await storePages(env, mergedPages);
|
await storePages(env, mergedPages);
|
||||||
console.log("Pages imported from Notion and merged with cache.");
|
console.log("Pages imported from Notion and merged with cache.");
|
||||||
return mergedPages;
|
return mergedPages;
|
||||||
|
|||||||
@ -134,9 +134,6 @@ export async function transformPageData(
|
|||||||
|
|
||||||
const showScroll = properties["Show Scroll Icon"]?.checkbox || false;
|
const showScroll = properties["Show Scroll Icon"]?.checkbox || false;
|
||||||
|
|
||||||
// Extract order property
|
|
||||||
const order = properties["Order"]?.number || 0;
|
|
||||||
|
|
||||||
if (showProperties == true) {
|
if (showProperties == true) {
|
||||||
content.push({
|
content.push({
|
||||||
type: "properties",
|
type: "properties",
|
||||||
@ -171,6 +168,5 @@ export async function transformPageData(
|
|||||||
showContactForm: showContactForm,
|
showContactForm: showContactForm,
|
||||||
hideMobileImage: hideMobileImage,
|
hideMobileImage: hideMobileImage,
|
||||||
invertHeader: invertHeader,
|
invertHeader: invertHeader,
|
||||||
order: order,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user