diff --git a/.astro/collections/resources.schema.json b/.astro/collections/resources.schema.json index 4b4d176..ee5d2e0 100644 --- a/.astro/collections/resources.schema.json +++ b/.astro/collections/resources.schema.json @@ -23,7 +23,7 @@ "format": "unix-time" } ], - "default": "2025-03-29T15:12:49.089Z" + "default": "2025-03-29T16:05:34.037Z" }, "description": { "type": "string", diff --git a/.cache/url-cache.json b/.cache/url-cache.json index 0cd109a..43c379f 100644 --- a/.cache/url-cache.json +++ b/.cache/url-cache.json @@ -670,7 +670,7 @@ }, "https://scholarworks.uni.edu/cgi/viewcontent.cgi?article=3680%5C&context=grp": { "isValid": false, - "timestamp": 1743261170564 + "timestamp": 1743264335400 }, "https://pmc.ncbi.nlm.nih.gov/articles/PMC10489002/": { "isValid": true, @@ -754,7 +754,7 @@ }, "https://journals.plos.org/plosone/article?id=10.1371%252Fjournal.pone.0288696": { "isValid": false, - "timestamp": 1743261171019 + "timestamp": 1743264335845 }, "https://www.youtube.com/watch?v=_a7usMe_K38": { "isValid": true, @@ -841,7 +841,7 @@ }, "https://www.toraytac.com/media/c3feb206-1398-4e0e-bca6-df7780f11745/tcCurg/TenCate%2520Advanced%2520Composites/Documents/Technical%2520papers/TenCate_chopped_fiber_thermoplastics_compression_molding_technical_paper.pdf": { "isValid": false, - "timestamp": 1743261171190 + "timestamp": 1743264336017 }, "https://youtu.be/qtZv96cifIU": { "isValid": true, diff --git a/.gitignore b/.gitignore index 6de2a79..96d055c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,8 @@ # Build output dist/ - # Dependencies node_modules/ - +.cache/chromium # Logs npm-debug.log* yarn-debug.log* diff --git a/astro.config.mjs b/astro.config.mjs index d10b78b..d522710 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -31,7 +31,7 @@ export default defineConfig({ enabled: false, }, i18n: { - locales: ["en"], + locales: ["en","es"], defaultLocale: "en", }, alias: { diff --git a/src/base/url.test.ts b/src/base/url.test.ts index 2abf93f..e4e3c7e 100644 --- a/src/base/url.test.ts +++ b/src/base/url.test.ts @@ -96,19 +96,13 @@ describe('URL Checker', () => { }); }); }); - - describe('checkUrl convenience function', () => { - it('should use the default checker', async () => { - const result = await checkUrl('https://example.com'); - expect(result.valid).toBe(true); - }); - }); }); describe('url screenshot', () => { const testUrl = 'https://www.youtube.com/watch?v=4LrrFz802To'; const testOutputDir = path.join(__dirname, '../../test-output'); const screenshotPath = path.join(testOutputDir, 'test-screenshot.png'); + const chromiumDir = path.join(process.cwd(), '.cache', 'chromium'); // Create test output directory if it doesn't exist beforeAll(() => { @@ -130,6 +124,13 @@ describe('url screenshot', () => { } }); + it('should create and use chromium user data directory', async () => { + await screenshot(testUrl); + expect(fs.existsSync(chromiumDir)).toBe(true); + // Check for typical Chrome profile directories + expect(fs.existsSync(path.join(chromiumDir, 'Default'))).toBe(true); + }, 60000); + it('should take a screenshot with explicit path', async () => { const resultPath = await screenshot(testUrl, { dstPath: screenshotPath, diff --git a/src/base/url.ts b/src/base/url.ts index c29605b..958a4ab 100644 --- a/src/base/url.ts +++ b/src/base/url.ts @@ -46,9 +46,16 @@ async function getGlobalBrowser(): Promise { return browserInitPromise; } + // Create chromium user data directory if it doesn't exist + const userDataDir = path.join(process.cwd(), '.cache', 'chromium'); + if (!fs.existsSync(userDataDir)) { + fs.mkdirSync(userDataDir, { recursive: true }); + } + browserInitPromise = puppeteer.launch({ headless: 'new' as any, - args: ['--ignore-certificate-errors', '--no-sandbox', '--disable-setuid-sandbox'] + args: ['--ignore-certificate-errors', '--no-sandbox', '--disable-setuid-sandbox'], + userDataDir }); try { diff --git a/src/config/config.ts b/src/config/config.ts index b33bf70..ed92f57 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -8,7 +8,7 @@ export const OSR_ROOT = () => path.resolve(resolve("${OSR_ROOT}")) export const LOGGING_NAMESPACE = 'polymech-site' export const TRANSLATE_CONTENT = true -export const LANGUAGES = ['en'] +export const LANGUAGES = ['en', 'es'] export const LANGUAGES_SITE = ['en', 'ar', 'de', 'ja', 'es', 'zh', 'fr'] export const LANGUAGES_PROD = ['en'] export const isRTL = (lang) => lang === 'ar'