-
Notifications
You must be signed in to change notification settings - Fork 90
Added auto page script #44
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
CalgaryWebStudios
wants to merge
3
commits into
CodeStitchOfficial:main
Choose a base branch
from
CalgaryWebStudios:page-script
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,46 @@ | ||
| { | ||
| "name": "intermediate-website-kit-less", | ||
| "version": "2.0.1", | ||
| "description": "The official CodeStitch Intermediate kit, featuring 11ty, Decap CMS and LESS - all set up for you! Perfect for websites of all sizes.", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "watch:cms": "npx decap-server", | ||
| "watch:eleventy": "cross-env ELEVENTY_ENV=DEV eleventy --serve", | ||
| "build:eleventy": "cross-env ELEVENTY_ENV=PROD eleventy", | ||
| "start": "run-p watch:*", | ||
| "build": "run-s build:*", | ||
| "preview": "cross-env ELEVENTY_ENV=PROD eleventy --serve", | ||
| "remove-dark-mode": "node scripts/remove-dark-mode.js", | ||
| "remove-decap": "node scripts/remove-decap.js", | ||
| "remove-demo": "node scripts/remove-demo.js" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/CodeStitchOfficial/Intermediate-Website-Kit-LESS.git" | ||
| }, | ||
| "keywords": [], | ||
| "author": "", | ||
| "license": "ISC", | ||
| "bugs": { | ||
| "url": "https://github.com/CodeStitchOfficial/Intermediate-Website-Kit-LESS/issues" | ||
| }, | ||
| "homepage": "https://github.com/CodeStitchOfficial/Intermediate-Website-Kit-LESS#readme", | ||
| "dependencies": { | ||
| "@11ty/eleventy": "^3.1.2", | ||
| "@codestitchofficial/eleventy-plugin-minify": "^1.1.3", | ||
| "@codestitchofficial/eleventy-plugin-sharp-images": "^2.2.0", | ||
| "@quasibit/eleventy-plugin-sitemap": "^2.2.0", | ||
| "autoprefixer": "^10.4.27", | ||
| "codestitch-sharp-image-automation": "^0.4.0", | ||
| "cross-env": "^10.1.0", | ||
| "cssnano": "^7.1.2", | ||
| "decap-server": "^3.5.2", | ||
| "esbuild": "^0.27.3", | ||
| "glob": "^13.0.6", | ||
| "less": "^4.5.1", | ||
| "netlify-plugin-cache": "^1.0.3", | ||
| "npm-run-all2": "^5.0.2", | ||
| "postcss": "^8.5.6" | ||
| } | ||
| "name": "intermediate-website-kit-less", | ||
| "version": "2.0.1", | ||
| "description": "The official CodeStitch Intermediate kit, featuring 11ty, Decap CMS and LESS - all set up for you! Perfect for websites of all sizes.", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "watch:cms": "npx decap-server", | ||
| "watch:eleventy": "cross-env ELEVENTY_ENV=DEV eleventy --serve", | ||
| "build:eleventy": "cross-env ELEVENTY_ENV=PROD eleventy", | ||
| "start": "run-p watch:*", | ||
| "build": "run-s build:*", | ||
| "preview": "cross-env ELEVENTY_ENV=PROD eleventy --serve", | ||
| "remove-dark-mode": "node scripts/remove-dark-mode.js", | ||
| "remove-decap": "node scripts/remove-decap.js", | ||
| "remove-demo": "node scripts/remove-demo.js", | ||
| "create-page": "node scripts/create-page.js" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/CodeStitchOfficial/Intermediate-Website-Kit-LESS.git" | ||
| }, | ||
| "keywords": [], | ||
| "author": "", | ||
| "license": "ISC", | ||
| "bugs": { | ||
| "url": "https://github.com/CodeStitchOfficial/Intermediate-Website-Kit-LESS/issues" | ||
| }, | ||
| "homepage": "https://github.com/CodeStitchOfficial/Intermediate-Website-Kit-LESS#readme", | ||
| "dependencies": { | ||
| "@11ty/eleventy": "^3.1.2", | ||
| "@codestitchofficial/eleventy-plugin-minify": "^1.1.3", | ||
| "@codestitchofficial/eleventy-plugin-sharp-images": "^2.2.0", | ||
| "@quasibit/eleventy-plugin-sitemap": "^2.2.0", | ||
| "autoprefixer": "^10.4.27", | ||
| "codestitch-sharp-image-automation": "^0.4.0", | ||
| "cross-env": "^10.1.0", | ||
| "cssnano": "^7.1.2", | ||
| "decap-server": "^3.5.2", | ||
| "esbuild": "^0.27.3", | ||
| "glob": "^13.0.6", | ||
| "less": "^4.5.1", | ||
| "netlify-plugin-cache": "^1.0.3", | ||
| "npm-run-all2": "^5.0.2", | ||
| "postcss": "^8.5.6" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| const fs = require("fs"); | ||
| const path = require("path"); | ||
|
|
||
| const input = process.argv[2]; | ||
|
|
||
| if (!input) { | ||
| console.log('Please provide page names. Example: npm run create-page -- "Contact, About, Services"'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const pages = input.split(",").map((p) => p.trim()); | ||
|
|
||
| const templatePath = path.join("src/content/pages", "_template.txt"); | ||
| let template = fs.readFileSync(templatePath, "utf8"); | ||
|
|
||
| pages.forEach((page) => { | ||
| const slug = page | ||
| .toLowerCase() | ||
| .replace(/[^a-z0-9\s-]/g, "") | ||
| .replace(/\s+/g, "-") | ||
| .replace(/-+/g, "-") | ||
| .replace(/^-+|-+$/g, ""); | ||
|
|
||
| if (!slug) return; | ||
|
|
||
| const htmlPath = path.join("src/content/pages", `${slug}.html`); | ||
| const lessPath = path.join("src/assets/less", `${slug}.less`); | ||
|
|
||
| // const pageTemplate = template.replaceAll("{{PAGE}}", slug); | ||
|
|
||
| fs.writeFileSync(htmlPath, template); | ||
| fs.writeFileSync(lessPath, ""); | ||
|
|
||
| console.log(`Created ${htmlPath} and ${lessPath}`); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| function filterTitleCase(value) { | ||
| return value | ||
| .split("-") | ||
| .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) | ||
| .join(" "); | ||
| } | ||
|
|
||
| module.exports = filterTitleCase; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,33 @@ | ||
| --- | ||
| title: "Page title for <title> and OG tags" | ||
| description: "Description for <meta> description and OG tags" | ||
| permalink: "/page-path/" | ||
| 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 }}" | ||
| permalink: "/{{ page.fileSlug | slugify }}/" | ||
| --- | ||
|
|
||
|
|
||
| {% extends "layouts/base.html" %} | ||
|
|
||
| {% block head %} | ||
| <!-- Any page-specific tags that belong in the <head>, such as a page-specific stylesheet --> | ||
|
|
||
| <link rel="stylesheet" href="/assets/css/{{ page.fileSlug }}.css"> | ||
|
|
||
| <!-- Any page-specific tags that belong in the <head> --> | ||
|
|
||
|
|
||
| {% endblock %} | ||
|
|
||
| {% block body %} | ||
|
|
||
| <!-- Page HTML goes here, without a <main> wrapper. The <main> tag is already presented in layouts/base.html --> | ||
| {% endblock %} | ||
|
|
||
| <!-- If you want the page to have a "CTA", uncomment the line below --> | ||
|
|
||
| <!-- {% include 'sections/cta.html' %} --> | ||
|
|
||
| {% endblock %} | ||
|
|
||
|
|
||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.