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

[Feature] Created sitemap #1267

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

manya706
Copy link
Contributor

@manya706 manya706 commented Oct 7, 2024

Linked Issue

closes #1170

Description

This pull request introduces a new generate-sitemap.mjs file to automatically generate and update the sitemap for the website. The script consolidates the sitemap generation logic and ensures it runs after the build process.

Methodology

New Script: Created generate-sitemap.mjs to generate the sitemap.
Postbuild Hook: Updated package.json to include a postbuild script that runs the sitemap generation script automatically after the build process.

Verification

  • Run Build:
pnpm run build
  • Generate Sitemap:
pnpm run generate-sitemap
  • Check Output: Verify sitemap.xml is generated correctly.

Code of Conduct

By submitting this pull request, you agree to follow our Code of Conduct

@manya706 manya706 requested a review from a team as a code owner October 7, 2024 18:38
Copy link

netlify bot commented Oct 7, 2024

👷 Deploy Preview for virtual-coffee-io processing.

Name Link
🔨 Latest commit e921ba5
🔍 Latest deploy log https://app.netlify.com/sites/virtual-coffee-io/deploys/670b577559ce9a0008184a77

Copy link
Member

@danieltott danieltott left a comment

Choose a reason for hiding this comment

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

Hey @manya706 - this is a really good start! A couple notes:

export async function generateStaticParams() {
  const newsletters = await getNewsletters();

  return newsletters.map((newsletter) => ({
    slug: newsletter.href.replace('/newsletter/issues/', ''),
  }));
}

We're using the getNewsletters function and getting url information that way. Each sub-section has a similar setup, you can search for generateStaticParams and find those.

If this is too much, that might be ok, and maybe we can start with the basic version that links to the top-level pages, and then improve it with further iterations. Take a look and let me know!

@danieltott
Copy link
Member

Oh one other thing - we should remove the public/sitemap.xml and have it ignored via .gitignore, since it is a generated file 👍

@manya706
Copy link
Contributor Author

hey @danieltott ! when i am importing generateStaticParams function, it keeps on giving me that the file cannot be located when i am putting the correct location url. could you help me with this? i have tried changing everything but its not locating the file

node:internal/modules/esm/resolve:265
    throw new ERR_MODULE_NOT_FOUND(
          ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\Users\manya\virtualcoffee.io\src\app\newsletter\issues\[slug]\page' imported from C:\Users\manya\virtualcoffee.io\src\app\newsletter\issues\[slug]\check.js
    at finalizeResolution (node:internal/modules/esm/resolve:265:11)
    at moduleResolve (node:internal/modules/esm/resolve:933:10)
    at defaultResolve (node:internal/modules/esm/resolve:1169:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:540:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:509:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:239:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:96:40)
    at link (node:internal/modules/esm/module_job:95:36) {
  code: 'ERR_MODULE_NOT_FOUND',
  url: 'file:///C:/Users/manya/virtualcoffee.io/src/app/newsletter/issues/[slug]/page'
}

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.

feat: create a sitemap.xml
2 participants