Last active
December 16, 2022 11:26
-
-
Save BenDMyers/9b548953170a8e1fab1590dd74a6f59f to your computer and use it in GitHub Desktop.
Bash function to create an Eleventy project
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
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" | |
} |
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
Should start
function 11() {
surely?