A few more tweaks

This commit is contained in:
Zach Leatherman 2023-01-23 12:34:39 -06:00
parent 447028c3a9
commit 87f15a24bd
4 changed files with 35 additions and 32 deletions

View File

@ -15,9 +15,9 @@ A starter repository showing how to build a blog with the [Eleventy](https://git
Deploy this Eleventy site in just a few clicks on these services: Deploy this Eleventy site in just a few clicks on these services:
- [Get your own Eleventy web site on Netlify](https://app.netlify.com/start/deploy?repository=https://github.com/11ty/eleventy-base-blog) - [Get your own Eleventy web site on Netlify](https://app.netlify.com/start/deploy?repository=https://github.com/11ty/eleventy-base-blog)
- If you run Eleventy locally you can drag your `_site` folder to [`drop.netlify.com`](https://drop.netlify.com/) to upload it!
- [Get your own Eleventy web site on Vercel](https://vercel.com/import/project?template=11ty%2Feleventy-base-blog) - [Get your own Eleventy web site on Vercel](https://vercel.com/import/project?template=11ty%2Feleventy-base-blog)
- Read more about [Deploying an Eleventy project](https://www.11ty.dev/docs/deployment/) to the web.
Or, read more about [Deploying an Eleventy project](https://www.11ty.dev/docs/deployment/).
## Getting Started ## Getting Started

View File

@ -8,7 +8,7 @@ Leverage agile frameworks to provide a robust synopsis for high level overviews.
Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring. Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring.
{% imageOptimized "./fourthpost/possum.png", "A possum parent and two possum kids hanging from the iconic red balloon" %} {% imageOptimized "./possum.png", "A possum parent and two possum kids hanging from the iconic red balloon" %}
## Section Header ## Section Header

View File

@ -5,8 +5,8 @@ const markdownItAnchor = require("markdown-it-anchor");
const pluginRss = require("@11ty/eleventy-plugin-rss"); const pluginRss = require("@11ty/eleventy-plugin-rss");
const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight"); const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const pluginNavigation = require("@11ty/eleventy-navigation"); const pluginNavigation = require("@11ty/eleventy-navigation");
const { EleventyHtmlBasePlugin } = require("@11ty/eleventy");
const eleventyImage = require("@11ty/eleventy-img"); const eleventyImage = require("@11ty/eleventy-img");
const { EleventyHtmlBasePlugin } = require("@11ty/eleventy");
function relativeToInputPath(inputPath, relativeFilePath) { function relativeToInputPath(inputPath, relativeFilePath) {
let split = inputPath.split(path.sep); let split = inputPath.split(path.sep);
@ -24,10 +24,6 @@ module.exports = function(eleventyConfig) {
"./node_modules/prismjs/themes/prism-okaidia.css": "/css/prism-okaidia.css" "./node_modules/prismjs/themes/prism-okaidia.css": "/css/prism-okaidia.css"
}); });
// If your passthrough copy gets heavy and cumbersome, add this line
// to emulate the file copy on the dev server. Learn more: https://www.11ty.dev/docs/copy/#emulate-passthrough-copy-during-serve
// eleventyConfig.setServerPassthroughCopyBehavior("passthrough");
// Plugins // Plugins
eleventyConfig.addPlugin(pluginRss); eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addPlugin(pluginSyntaxHighlight); eleventyConfig.addPlugin(pluginSyntaxHighlight);
@ -35,12 +31,14 @@ module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(EleventyHtmlBasePlugin); eleventyConfig.addPlugin(EleventyHtmlBasePlugin);
// Shortcodes // Shortcodes
eleventyConfig.addPlugin(eleventyConfig => {
eleventyConfig.addAsyncShortcode("imageOptimized", async function imageShortcode(src, alt, sizes) { eleventyConfig.addAsyncShortcode("imageOptimized", async function imageShortcode(src, alt, sizes) {
let file = relativeToInputPath(this.page.inputPath, src); let file = relativeToInputPath(this.page.inputPath, src);
let metadata = await eleventyImage(file, { let metadata = await eleventyImage(file, {
widths: ["auto"], widths: ["auto"],
formats: ["webp", "png"], // Can add "avif" or "jpeg" here // Can add "avif" or "jpeg" here if youd like!
outputDir: "_site/img/" formats: ["webp", "png"],
outputDir: path.join(eleventyConfig.dir.output, "img"),
}); });
let imageAttributes = { let imageAttributes = {
alt, alt,
@ -50,6 +48,7 @@ module.exports = function(eleventyConfig) {
}; };
return eleventyImage.generateHTML(metadata, imageAttributes); return eleventyImage.generateHTML(metadata, imageAttributes);
}); });
})
// Filters // Filters
eleventyConfig.addFilter("readableDate", (dateObj, format = "dd LLLL yyyy") => { eleventyConfig.addFilter("readableDate", (dateObj, format = "dd LLLL yyyy") => {
@ -104,6 +103,14 @@ module.exports = function(eleventyConfig) {
}); });
}); });
// Features to make your build faster (as you need them)
// If your passthrough copy gets heavy and cumbersome, add this line
// to emulate the file copy on the dev server. Learn more:
// https://www.11ty.dev/docs/copy/#emulate-passthrough-copy-during-serve
// eleventyConfig.setServerPassthroughCopyBehavior("passthrough");
return { return {
// Control which files Eleventy will process // Control which files Eleventy will process
// e.g.: *.md, *.njk, *.html, *.liquid // e.g.: *.md, *.njk, *.html, *.liquid
@ -126,10 +133,11 @@ module.exports = function(eleventyConfig) {
includes: "_includes", includes: "_includes",
data: "_data", data: "_data",
output: "_site" output: "_site"
} },
// ----------------------------------------------------------------- // -----------------------------------------------------------------
// Optional: // Optional items:
// -----------------------------------------------------------------
// If your site deploys to a subdirectory, change `pathPrefix`. // If your site deploys to a subdirectory, change `pathPrefix`.
// Read more: https://www.11ty.dev/docs/config/#deploy-to-a-subdirectory-with-a-path-prefix // Read more: https://www.11ty.dev/docs/config/#deploy-to-a-subdirectory-with-a-path-prefix
@ -137,9 +145,6 @@ module.exports = function(eleventyConfig) {
// When paired with the HTML <base> plugin https://www.11ty.dev/docs/plugins/html-base/ // When paired with the HTML <base> plugin https://www.11ty.dev/docs/plugins/html-base/
// it will transform any absolute URLs in your HTML to include this // it will transform any absolute URLs in your HTML to include this
// folder name and does **not** affect where things go in the output folder. // folder name and does **not** affect where things go in the output folder.
pathPrefix: "/",
// Optional (default is shown)
// pathPrefix: "/",
// -----------------------------------------------------------------
}; };
}; };

View File

@ -5,12 +5,10 @@
"scripts": { "scripts": {
"build": "npx @11ty/eleventy", "build": "npx @11ty/eleventy",
"build-ghpages": "npx @11ty/eleventy --pathprefix=/eleventy-base-blog/", "build-ghpages": "npx @11ty/eleventy --pathprefix=/eleventy-base-blog/",
"bench": "DEBUG=Eleventy:Benchmark* npx @11ty/eleventy",
"watch": "npx @11ty/eleventy --watch",
"serve": "npx @11ty/eleventy --serve", "serve": "npx @11ty/eleventy --serve",
"start": "npx @11ty/eleventy --serve --quiet", "start": "npx @11ty/eleventy --serve --quiet",
"start-ghpages": "npx @11ty/eleventy --serve --quiet --pathprefix=/eleventy-base-blog/", "debug": "DEBUG=Eleventy* npx @11ty/eleventy",
"debug": "DEBUG=Eleventy* npx @11ty/eleventy" "benchmark": "DEBUG=Eleventy:Benchmark* npx @11ty/eleventy"
}, },
"repository": { "repository": {
"type": "git", "type": "git",