Skip to content

Instantly share code, notes, and snippets.

@BenDMyers
Last active December 16, 2022 11:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save BenDMyers/9b548953170a8e1fab1590dd74a6f59f to your computer and use it in GitHub Desktop.
Save BenDMyers/9b548953170a8e1fab1590dd74a6f59f to your computer and use it in GitHub Desktop.
Bash function to create an Eleventy project
function el() {
mkdir "$1"
cd "$1"
git init
mkdir -p src/_data/
mkdir src/_includes/
# Populate .gitignore
echo "# Node" >> .gitignore
echo "node_modules/" >> .gitignore
echo "package-lock.json" >> .gitignore
echo "yarn.lock" >> .gitignore
echo "\n# Eleventy" >> .gitignore
echo "_site/" >> .gitignore
# Populate .eleventy.js
echo "/**" >> .eleventy.js
echo " * @typedef {import('@11ty/eleventy/src/UserConfig')} EleventyConfig" >> .eleventy.js
echo " * @typedef {ReturnType<import('@11ty/eleventy/src/defaultConfig')>} EleventyReturnValue" >> .eleventy.js
echo " * @type {(eleventyConfig: EleventyConfig)) => EleventyReturnValue}" >> .eleventy.js
echo " */" >> .eleventy.js
echo "module.exports = function (eleventyConfig) {" >> .eleventy.js
echo "\treturn {" >> .eleventy.js
echo "\t\tdir: {" >> .eleventy.js
echo "\t\t\tinput: 'src'" >> .eleventy.js
echo "\t\t}" >> .eleventy.js
echo "\t};" >> .eleventy.js
echo -n "};" >> .eleventy.js
npm init -y
sed -i '' 's/"test": "echo \\"Error: no test specified\\" && exit 1"/"build": "eleventy",\n "dev": "eleventy --serve"/' package.json
npm install @11ty/eleventy
git add .
git commit -m "Initialize Eleventy project"
}
@neilgilmour
Copy link

Should start function 11() { surely?

@BenDMyers
Copy link
Author

Should start function 11() { surely?

Ha, I looked into it, @neilgilmour, and Bash functions can’t start with numbers unfortunately.

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