Skip to content

Added auto page script#44

Open
CalgaryWebStudios wants to merge 3 commits intoCodeStitchOfficial:mainfrom
CalgaryWebStudios:page-script
Open

Added auto page script#44
CalgaryWebStudios wants to merge 3 commits intoCodeStitchOfficial:mainfrom
CalgaryWebStudios:page-script

Conversation

@CalgaryWebStudios
Copy link

I added a new file called "create-page.js" in the scripts folder, what it does is it auto generates 1 or multiple pages for the user, and it automatically creates its corresponding .LESS file as well, it places everything in the correct directories and it auto pastes the _template.txt.

I updated _template.txt so now it will automatically populate the permalink section with the HTML file slug, and the page title will automatically be set to "Page Name | Client | City, State". Another change I made was to auto-link the new generated CSS file in the head. Another repetitive task fully automated.

To allow for these changes, I added a new custom filter in ".eleventy.js" on line 87.

I also updated the package.json with the command name, I used "new-page"

USAGE:

  1. Open Terminal in VSCode
  2. Type "npm run new-page -- "Page One, Page Two, Page Three" OR "npm run new-page -- "Page One"
  3. It will auto create page-one.html and page-one.less + Auto paste the _template.txt, saving the developer a lot of repetitive work.

I hope you find this useful for the Code Stitch community! If not, no worries, but for me personally, it saves a ton of time!

@netlify
Copy link

netlify bot commented Mar 9, 2026

👷 Deploy request for codestitch-intermediate pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 3b18d4c

@BuckyBuck135
Copy link
Contributor

The core idea is solid and genuinely useful. Thanks for the contribution @CalgaryWebStudios !

Apart from the bug fixes and small tweaks I've highlighted above, there are consistencies I'd like to maintain in the way code is written and formatted, and I think there should also be a new section in the readme to explain how to use the script.

I'm going to prepare some changes on my branch. In the meantime, feel free to chime in on my code review comments.

Thanks again and looking forward to hearing from you.

@CalgaryWebStudios
Copy link
Author

Thanks for taking a look @BuckyBuck135! I looked in the files changed and could not find any comments that were left, perhaps I am missing something?

Looking forward to seeing the changes on your branch!

description: "Meta description for the page"
image: "OPTIONAL - If an image path is specified here, it will be used for that page's OG image. Useful for blog posts (implemented as standard with this kit)"
eleventyComputed:
title: "{{ page.fileSlug | titleCase }} | {{ client.name }} | {{ client.address.city }}, {{ client.address.state }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'd rather NOT have an opinionated, computed value for the title to keep it simple for the developer. Current pages use a simple string value for the title, and the computed version requires some level of understanding of the Eleventy cascade and project.
Thoughts?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah I fully understand where your coming from, the way that I see it is that most people would follow the original title structure in the kit which is "About Us | Johns Plumbing", and instead of manually typing it as a string, it could be automated, with the addition of "City, State" so "About Us | Johns Plumbing | Calgary, AB".

Yes you are correct that it requires some level of understanding, but so does the rest of the kit, in my opinion.

@BuckyBuck135
Copy link
Contributor

Thanks for taking a look @BuckyBuck135! I looked in the files changed and could not find any comments that were left, perhaps I am missing something?

Looking forward to seeing the changes on your branch!

Sorry, I forgot to submit the review lol

@CalgaryWebStudios
Copy link
Author

Fixed naming inconsistensies, cleaned up extra code, refactored the titleCase filter, optional CTA in _template.txt. Let me know what you think.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants