Skip to content

changes to resolve build issue #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export default defineConfig({
site: config.site.base_url ? config.site.base_url : "http://examplesite.com",
base: config.site.base_path ? config.site.base_path : "/",
trailingSlash: config.site.trailing_slash ? "always" : "ignore",
output: "static",
build: {
format: 'directory',
assets: '_assets',
},
i18n: {
locales: filteredSupportedLang,
defaultLocale: default_language,
Expand All @@ -31,7 +36,9 @@ export default defineConfig({
service: squooshImageService(),
},
integrations: [
react(),
react({
include: ['**/Youtube.tsx', '**/*.tsx'],
}),
sitemap(),
tailwind({
applyBaseStyles: false,
Expand Down Expand Up @@ -65,4 +72,22 @@ export default defineConfig({
},
extendDefaultPlugins: true,
},
vite: {
build: {
sourcemap: false,
minify: true,
rollupOptions: {
output: {
manualChunks: undefined,
},
},
},
optimizeDeps: {
include: ['react-lite-youtube-embed'],
exclude: ['@astrojs/mdx'],
},
ssr: {
noExternal: ['react-lite-youtube-embed'],
},
},
});
23 changes: 21 additions & 2 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
[build]
publish = "dist"
command = "yarn build"
command = "yarn install --frozen-lockfile && yarn generate-json && yarn build"
publish = "dist"

[build.environment]
NODE_VERSION = "20"
NODE_ENV = "production"
YARN_FLAGS = "--frozen-lockfile"
NETLIFY_USE_YARN = "true"

[build.processing]
skip_processing = false

[[redirects]]
from = "/*"
to = "/index.html"
status = 200

[[headers]]
for = "/*"
[headers.values]
X-Frame-Options = "DENY"
X-XSS-Protection = "1; mode=block"
X-Content-Type-Options = "nosniff"
Referrer-Policy = "strict-origin-when-cross-origin"
96 changes: 62 additions & 34 deletions scripts/jsonGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,20 @@ const BLOG_FOLDER = "blog";

// get data from markdown
const getData = (folder, groupDepth, langIndex = 0) => {
console.log(`Processing folder: ${folder}`);

const getPaths = languages
.map((lang, index) => {
const langFolder = lang.contentDir ? lang.contentDir : lang.languageCode;
const dir = path.join(CONTENT_ROOT, folder, langFolder);

console.log(`Checking directory: ${dir}`);

if (!fs.existsSync(dir)) {
console.warn(`Directory does not exist: ${dir}`);
return [];
}

return fs
.readdirSync(dir)
.filter(
Expand All @@ -23,38 +33,45 @@ const getData = (folder, groupDepth, langIndex = 0) => {
)
.flatMap((filename) => {
const filepath = path.join(dir, filename);
const stats = fs.statSync(filepath);
const isFolder = stats.isDirectory();
console.log(`Processing file: ${filepath}`);

try {
const stats = fs.statSync(filepath);
const isFolder = stats.isDirectory();

if (isFolder) {
return getData(filepath, groupDepth, index);
} else {
const file = fs.readFileSync(filepath, "utf-8");
const { data, content } = matter(file);
const pathParts = filepath.split(path.sep);

let slug;
if (data.slug) {
const slugParts = data.slug.split("/");
slugParts[0] = BLOG_FOLDER;
slug = slugParts.join("/");
if (isFolder) {
return getData(filepath, groupDepth, index);
} else {
slug = pathParts
.slice(CONTENT_DEPTH)
.join("/")
.replace(/\.[^/.]+$/, "");
slug = `${BLOG_FOLDER}/${slug.split("/").slice(1).join("/")}`;
}
data.slug = slug;
const group = "blog";
const file = fs.readFileSync(filepath, "utf-8");
const { data, content } = matter(file);
const pathParts = filepath.split(path.sep);

let slug;
if (data.slug) {
const slugParts = data.slug.split("/");
slugParts[0] = BLOG_FOLDER;
slug = slugParts.join("/");
} else {
slug = pathParts
.slice(CONTENT_DEPTH)
.join("/")
.replace(/\.[^/.]+$/, "");
slug = `${BLOG_FOLDER}/${slug.split("/").slice(1).join("/")}`;
}
data.slug = slug;
const group = "blog";

return {
lang: languages[index].languageCode, // Set the correct language code dynamically
group: group,
slug: data.slug,
frontmatter: data,
content: content,
};
return {
lang: languages[index].languageCode,
group: group,
slug: data.slug,
frontmatter: data,
content: content,
};
}
} catch (error) {
console.error(`Error processing file ${filepath}:`, error);
return [];
}
});
})
Expand All @@ -65,21 +82,32 @@ const getData = (folder, groupDepth, langIndex = 0) => {
};

try {
console.log("Starting JSON generation...");

// create folder if it doesn't exist
if (!fs.existsSync(JSON_FOLDER)) {
fs.mkdirSync(JSON_FOLDER);
console.log(`Creating JSON folder: ${JSON_FOLDER}`);
fs.mkdirSync(JSON_FOLDER, { recursive: true });
}

// create json files
const posts = getData(BLOG_FOLDER, 3);
console.log(`Generated ${posts.length} posts`);

fs.writeFileSync(
`${JSON_FOLDER}/posts.json`,
JSON.stringify(getData(BLOG_FOLDER, 3)),
JSON.stringify(posts, null, 2)
);

// merge json files for search
const posts = require(`../${JSON_FOLDER}/posts.json`);
const search = [...posts];
fs.writeFileSync(`${JSON_FOLDER}/search.json`, JSON.stringify(search));
fs.writeFileSync(
`${JSON_FOLDER}/search.json`,
JSON.stringify(search, null, 2)
);

console.log("JSON generation completed successfully");
} catch (err) {
console.error(err);
console.error("Error during JSON generation:", err);
process.exit(1);
}
4 changes: 4 additions & 0 deletions src/content/blog/english/khc.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ So if you're planning to join SRM-RMP, don’t just believe the brochures or the

This post isn’t to bash the institution. It’s just the side of the story that doesn't make it to the official website.

<<<<<<< HEAD
---
=======
---

## Contact

Have a story or experience from your own campus you want to share anonymously?
>>>>>>> upstream/main