Skip to content
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

[DEV-2129] Sitemap for standalone version #1368

Open
wants to merge 1 commit into
base: poc-standalone
Choose a base branch
from

Conversation

tommaso1
Copy link
Collaborator

@tommaso1 tommaso1 commented Mar 5, 2025

List of Changes

Restore sitemp for standalone version including guides data fetched from S3 and the script to save it

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Chore (nothing changes by a user perspective)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@tommaso1 tommaso1 requested review from MarcoPonchia, marcobottaro and a team as code owners March 5, 2025 15:06
Copy link

changeset-bot bot commented Mar 5, 2025

🦋 Changeset detected

Latest commit: 1209755

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
nextjs-website Major
infrastructure Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@tommaso1 tommaso1 changed the base branch from main to poc-standalone March 5, 2025 15:07
Copy link
Contributor

github-actions bot commented Mar 5, 2025

This PR exceeds the recommended size of 800 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

Copy link
Contributor

github-actions bot commented Mar 5, 2025

Jira Pull Request Link

This Pull Request refers to the following Jira issue DEV-2129

Copy link
Contributor

github-actions bot commented Mar 5, 2025

Bundle not found for branch main.
It wasn't possible to compare bundles size.

Comment on lines +34 to +41
// Debug environment variables
console.log('Environment variables:');
console.log(`S3_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID ? '****' : 'not set'}`);
console.log(
`S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY ? '****' : 'not set'}`
);
console.log(`S3_BUCKET_NAME: ${S3_BUCKET_NAME || 'not set'}`);
console.log(`S3_PATH_TO_GITBOOK_DOCS: ${S3_PATH_TO_GITBOOK_DOCS}`);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Debug environment variables
console.log('Environment variables:');
console.log(`S3_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID ? '****' : 'not set'}`);
console.log(
`S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY ? '****' : 'not set'}`
);
console.log(`S3_BUCKET_NAME: ${S3_BUCKET_NAME || 'not set'}`);
console.log(`S3_PATH_TO_GITBOOK_DOCS: ${S3_PATH_TO_GITBOOK_DOCS}`);

const S3_SECRET_ACCESS_KEY = process.env.S3_SECRET_ACCESS_KEY;
const S3_BUCKET_NAME = process.env.S3_BUCKET_NAME;
const S3_PATH_TO_GITBOOK_DOCS = process.env.S3_PATH_TO_GITBOOK_DOCS || 'docs';
const AWS_REGION = 'eu-south-1'; // Using the region from your .env file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const AWS_REGION = 'eu-south-1'; // Using the region from your .env file
const AWS_REGION = process.env.NEXT_PUBLIC_COGNITO_REGION;

Comment on lines +149 to +159
// Function to extract title from markdown content
function extractTitleFromMarkdown(content: string): string {
const titleMatch = content.match(/^#\s+(.+)$/m);
if (titleMatch) {
let title = titleMatch[1].trim();
// Remove any emojis or special characters
title = title.replace(/[\u{1F600}-\u{1F6FF}]/gu, '');
return title;
}
return 'Untitled';
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont know if this function do the same thing but you can find parseTitle in apps/nextjs-website/src/helpers/parseS3Doc.helpers.ts that extract the title from the markdown.

function generateUrlPathWithStrapiData(
dirName: string,
filePath: string,
strapiGuides: StrapiGuide[],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
strapiGuides: StrapiGuide[],

};
};
};
[key: string]: any;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this file is not necessary

Suggested change
[key: string]: any;

function generateUrlPathWithStrapiData(
dirName: string,
filePath: string,
strapiGuides: StrapiGuide[],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think is not used anymore

Suggested change
strapiGuides: StrapiGuide[],

Comment on lines +298 to +300
for (let i = 0; i < Math.min(dirNames.length, strapiGuides.length); i++) {
dirToGuideMap[dirNames[i]] = strapiGuides[i];
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don think this could function properly... i think you should add some matching that checks strapiGuide dirName with S3 dirName 🤔

Comment on lines +387 to +391
// Also write a sample item to the console
if (sitemapItems.length > 0) {
console.log('Sample sitemap item:');
console.log(JSON.stringify(sitemapItems[0], null, 2));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Also write a sample item to the console
if (sitemapItems.length > 0) {
console.log('Sample sitemap item:');
console.log(JSON.stringify(sitemapItems[0], null, 2));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants