diff --git a/.gitignore b/.gitignore
index 0037fd0..6c00047 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,4 +24,5 @@ pnpm-lock.yaml
#cached openai responses
-.aicache/
\ No newline at end of file
+.aicache/
+.vercel/output/
diff --git a/astro.config.mjs b/astro.config.mjs
index 178c96d..7af0a5c 100644
--- a/astro.config.mjs
+++ b/astro.config.mjs
@@ -7,9 +7,11 @@ import astroI18next from "astro-i18next";
import vercel from '@astrojs/vercel/static';
+console.log("Ouptut dir: " + SITE.outDir);
// https://astro.build/config
export default defineConfig({
trailingSlash: "always", //Sitemap uses trailing /, we gotta be consistent. This affects dev and production differently
+ outDir: SITE.outDir,
integrations: [
// Enable Preact to support Preact JSX components.
preact(),
diff --git a/package.json b/package.json
index 37eba3a..2670c81 100644
--- a/package.json
+++ b/package.json
@@ -7,13 +7,16 @@
"dev": "astro dev",
"start": "astro dev",
"build": "astro build",
+ "build-imgstyle": "tsx tasks/switch.ts imgstyle && astro build && tsx tasks/switch.ts srcset",
"preview": "astro preview",
"astro": "astro",
+ "switch": "tsx tasks/switch.ts",
"translate": "tsx tasks/translate.ts",
"localize": "tsx tasks/localize.ts",
"jsonld": "tsx tasks/jsonld.ts",
"feedback": "tsx tasks/ai_feedback.ts",
- "dates": "tsx tasks/update-frontmatter-dates.ts"
+ "dates": "tsx tasks/update-frontmatter-dates.ts",
+ "site-info": "tsx tasks/site_info.ts"
},
"dependencies": {
"@algolia/client-search": "^4.13.1",
diff --git a/public/locales/en/imgstyle.json b/public/locales/en/imgstyle.json
new file mode 100644
index 0000000..d4f5568
--- /dev/null
+++ b/public/locales/en/imgstyle.json
@@ -0,0 +1,12 @@
+{
+ "siteTitleSuffix": " - img.style",
+ "siteTitleName": "image styling & optimization",
+ "skipToContentText": "Skip to Content",
+ "editPage": "Edit this page",
+ "joinCommunity": "Join our community",
+ "footerLicense": "This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License",
+ "translatedContentDisclaimer": "Please let us know if something isn't right. Our translator isn't quite sentient yet, but does incorporate feedback, so please leave some tips!",
+ "reportIssue": "Get in touch on Github",
+ "sidebarTitle": "Topics",
+ "communitySidebarTitle": "Community"
+}
diff --git a/src/consts.ts b/src/consts.ts
index 55a3438..5f118f9 100644
--- a/src/consts.ts
+++ b/src/consts.ts
@@ -2,6 +2,8 @@ import SITE_INFO from './site-info';
export const SITE = SITE_INFO;
+export const SITES_KEYS = ['srcset', 'imgstyle'];
+
export const CONTENT_COLLECTIONS = ['docs', 'imgstyle'];
export const GITHUB_EDIT_URL = `https://github.com/imazen/sites/tree/main`;
diff --git a/src/site-info.imgstyle.ts b/src/site-info.imgstyle.ts
index 9d6095f..9ee81e9 100644
--- a/src/site-info.imgstyle.ts
+++ b/src/site-info.imgstyle.ts
@@ -4,11 +4,12 @@ export default {
title: ' layout and reference', // Used for logo text and og:sitename
titleSuffix: ' - img.style', // Appended to page content title
description: 'Examples and tools for image layout and styling',
- defaultLanguage: 'en-us',
+ defaultLanguage: 'en',
address: 'https://www.img.style',
defaultLocale: 'en',
algoliaIndex: 'imgstyle',
algoliaDomain: 'img.style',
contentCollection: 'imgstyle',
- translationNamespace: 'imgstyle'
+ translationNamespace: 'imgstyle',
+ outDir: './dist-imgstyle',
} as const;
diff --git a/src/site-info.srcset.ts b/src/site-info.srcset.ts
index 9705c00..3853644 100644
--- a/src/site-info.srcset.ts
+++ b/src/site-info.srcset.ts
@@ -6,8 +6,10 @@ export default {
description: 'Templates, guides, examples, and tools for correct and efficient responsive images',
defaultLanguage: 'en',
address: 'https://www.srcset.tips/',
- algoliaIndex: 'srcset', //
+ algoliaIndex: 'srcset',
+ defaultLocale: 'en',
algoliaDomain: 'srcset.tips',
contentCollection: 'docs',
- translationNamespace: 'srcset'
+ translationNamespace: 'srcset',
+ outDir: './dist',
} as const;
diff --git a/tasks/site_info.ts b/tasks/site_info.ts
new file mode 100644
index 0000000..220f3f8
--- /dev/null
+++ b/tasks/site_info.ts
@@ -0,0 +1,6 @@
+import { SITE } from "../src/consts";
+
+// print info
+
+console.log("SITE", SITE);
+
diff --git a/tasks/switch.ts b/tasks/switch.ts
new file mode 100644
index 0000000..d337734
--- /dev/null
+++ b/tasks/switch.ts
@@ -0,0 +1,10 @@
+import { switchSite } from "./switch_sites";
+import { CONTENT_COLLECTIONS } from "../src/consts";
+
+const site = process.argv[2];
+if (!site) {
+ console.error("Please specify site key such as 'srcset' or 'imgstyle'. Ex. npm run switch -- srcset OR npm run switch -- imgstyle");
+}else{
+ switchSite(site);
+}
+
diff --git a/tasks/switch_sites.ts b/tasks/switch_sites.ts
new file mode 100644
index 0000000..4b8dc02
--- /dev/null
+++ b/tasks/switch_sites.ts
@@ -0,0 +1,66 @@
+import fs from 'fs';
+import path from 'path';
+import { SITES_KEYS } from "../src/consts";
+
+async function searchFilenamesRecursive(directory: string, include: string): Promise {
+ const entries = await fs.promises.readdir(directory, { withFileTypes: true });
+ const files: string[] = [];
+
+ for (const entry of entries) {
+ const fullPath = path.join(directory, entry.name);
+ if (entry.isDirectory()) {
+ const subDirectoryFiles = await searchFilenamesRecursive(fullPath, include);
+ files.push(...subDirectoryFiles);
+ } else if (entry.isFile() && entry.name.includes(include)) {
+ files.push(fullPath);
+ }
+ }
+ return files;
+}
+
+async function switchSymlinks(directory: string, newSitekey: string) {
+ const searchPart = `.${newSitekey}.`;
+ const files = await searchFilenamesRecursive(directory, searchPart);
+ for (const newFile of files) {
+ const defaultFile = newFile.replace(searchPart, '.');
+ // Check if defaultFile is a symlink
+ const stats = await fs.promises.lstat(defaultFile);
+ if (stats.isSymbolicLink()) {
+ // print what it points to
+ const link = await fs.promises.readlink(defaultFile);
+ // if link is already newFile, skip
+ if (link === newFile) {
+ console.log('Link already exists from ' + defaultFile + " to " + link);
+ continue;
+ }
+ console.log('Unlinking ' + defaultFile + ' from using ' + link);
+ // delete symlink
+ await fs.promises.unlink(defaultFile);
+ // symlink defaultFile to newFile
+ console.log('Linking ' + defaultFile + ' to use ' + newFile);
+ await fs.promises.symlink(newFile, defaultFile);
+ } else {
+ console.log('!!!! Error, not a symlink: ' + defaultFile);
+
+ console.log('Not a symlink');
+ }
+ }
+}
+export async function switchSite(siteKey: string) {
+ // check siteKey is valid
+ if (!SITES_KEYS.includes(siteKey)) {
+ console.log('Error: invalid site key (' + siteKey + ')');
+ return;
+ }
+
+ console.log('Switching active site to ' + siteKey);
+
+ // check the current folder contains 'astro.config.mjs', if not fail
+ const astroConfigPath = path.join(process.cwd(), 'astro.config.mjs');
+ if (!fs.existsSync(astroConfigPath)) {
+ console.log('Error: astro.config.mjs not found in current directory. Run this from root');
+ return;
+ }
+
+ await switchSymlinks(process.cwd(), siteKey);
+}