diff --git a/components/solutions/SolutionView.jsx b/components/solutions/SolutionView.jsx index 625ab567..2bd24227 100644 --- a/components/solutions/SolutionView.jsx +++ b/components/solutions/SolutionView.jsx @@ -23,7 +23,7 @@ export function SolutionView({ }) { - console.log('SolutionView:menuStructure: ', menuStructure) + // console.log('SolutionView:menuStructure: ', menuStructure) const navDrawerWidth = 300; const topBarHeight = 64; const [menuOpen, setMenuOpen] = useState(true); @@ -70,7 +70,7 @@ export function SolutionView({ }} > {/* {frontmatter && } */} - {frontmatter?.title && frontmatter.title} + {frontmatter?.title && frontmatter.title} {frontmatter?.format === 'presentation' && diff --git a/constants/baseTheme.js b/constants/baseTheme.js index 11e0d916..29a1c55f 100644 --- a/constants/baseTheme.js +++ b/constants/baseTheme.js @@ -146,15 +146,19 @@ const baseTheme = deepmerge( color: palette.palette.text.highlight, }, ul: { - display: 'inline', + display: 'inline-block', breakInside: 'avoid-column', listStyleType: 'circle', li: { listStylePosition: 'inside', "::marker": { color: 'tertiary', - } - } + }, + span: { + display: 'inline', + }, + }, + }, table: { display: "inline-table", diff --git a/lib/content/menus.js b/lib/content/menus.js index 7a9415ad..0ac78f1c 100644 --- a/lib/content/menus.js +++ b/lib/content/menus.js @@ -40,7 +40,7 @@ async function getSolutions(siteConfig) { }); }); const content = await Promise.all(solutionsContentPromises); - await cacheWrite(cacheKey, JSON.stringify(content), 600); // cache for 10 minutes + await cacheWrite(cacheKey, JSON.stringify(content), 60*60*24); // cache for 24 hours return content } @@ -77,7 +77,7 @@ async function getKnowledge(siteConfig) { }); const content = await Promise.all(knowledgeContentPromises); - await cacheWrite(cacheKey, JSON.stringify(content), 600); // cache for 10 minutes + await cacheWrite(cacheKey, JSON.stringify(content), 60*60*24); // cache for 24 hours return content @@ -186,6 +186,6 @@ export async function getMenuStructureSolutions(siteConfig) { const content = { solutionMenu, chapterFiles, knowledgeFiles, designFiles: null }; - await cacheWrite(cacheKey, JSON.stringify(content), 600); // cache for 10 minutes + await cacheWrite(cacheKey, JSON.stringify(content), 60*60*24); // cache for 24 hours return content } diff --git a/lib/github/index.js b/lib/github/index.js index 884c076f..d1e1f21d 100644 --- a/lib/github/index.js +++ b/lib/github/index.js @@ -83,7 +83,7 @@ export async function getFileContent(owner, repo, branch, path) { // Check if the content is in the cache const cachedContent = await cacheRead(cacheKey); if (cachedContent) { - // console.info('[Github][Cache][HIT]:',cacheKey ) + console.info('[Github][Cache][HIT]:',cacheKey ) // If the content was found in the cache, return it return cachedContent; } else { diff --git a/lib/redis/index.js b/lib/redis/index.js index 2d2a6c83..ee7d34e0 100644 --- a/lib/redis/index.js +++ b/lib/redis/index.js @@ -79,15 +79,17 @@ export async function createRedisInstance(config = getRedisConfiguration()) { throw new Error(`[Redis] Could not create a Redis instance`); } } - +// Function to write data to the cache export async function cacheWrite(key, value, ttl = null) { if (!redisInstance) { redisInstance = await createRedisInstance(); } - + const isBuffer = Buffer.isBuffer(value); + const stringifiedValue = isBuffer ? JSON.stringify({ buffer: [...value] }) : JSON.stringify(value); + if (ttl) { try { - await redisInstance.set(key, value, "EX", ttl); + await redisInstance.set(key, stringifiedValue, "EX", ttl); return true; // or return 'Data set successfully'; } catch (error) { console.error(`Error setting data: ${error}`); @@ -95,7 +97,7 @@ export async function cacheWrite(key, value, ttl = null) { } } else { try { - await redisInstance.set(key, value); + await redisInstance.set(key, stringifiedValue); return true; // or return 'Data set successfully'; } catch (error) { console.error(`Error setting data: ${error}`); @@ -104,9 +106,14 @@ export async function cacheWrite(key, value, ttl = null) { } } +// Function to read data from the cache export async function cacheRead(key) { if (!redisInstance) { redisInstance = await createRedisInstance(); } - return await redisInstance.get(key); + const value = await redisInstance.get(key); + if (!value) return null; + const parsedValue = JSON.parse(value); + + return parsedValue.buffer ? Buffer.from(parsedValue.buffer) : parsedValue; } diff --git a/pages/api/content/[owner]/[repo].js b/pages/api/content/[owner]/[repo].js index 41f34691..014d9689 100644 --- a/pages/api/content/[owner]/[repo].js +++ b/pages/api/content/[owner]/[repo].js @@ -32,7 +32,7 @@ export default async function handler(req, res) { // // console.log('api:data: ', contentType, data); res.setHeader("Content-Type", contentType); res.send(data); - // res.send(Buffer.from(data, "base64")); + // res.end(Buffer.from(data, "base64")); // const content = Buffer.from(data.content ?? "", "base64").toString("utf8"); // res.status(200).json({ data }); }