Skip to content
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

Eleventy v3 #902

Merged
merged 48 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
3b969da
Update to @11/eleventy@ v3
mphstudios Jan 11, 2024
99481d2
Remove Handlebars template formats
mphstudios Jan 24, 2024
e1e127a
Set type module in package configuration
mphstudios Jan 24, 2024
3bf488e
Use ESM export statements
mphstudios Jan 24, 2024
ae3e3c8
Rewrite require statements as import statements
mphstudios Jan 24, 2024
6ab4f13
Replace module aliases with node subpath
mphstudios Jan 24, 2024
dbc44e3
Update @11ty/eleventy-img major version
mphstudios Feb 14, 2024
88ec231
Configure Eleventy Image plugin
mphstudios Feb 15, 2024
3b8a205
Update sharp minor version
mphstudios Feb 15, 2024
a59f3a1
Update IIIF dependencies
mphstudios Feb 15, 2024
a382c08
Use import statements in eleventy config
mphstudios Feb 15, 2024
2db61b0
Update loglevel minor version
mphstudios Feb 15, 2024
df3da0d
Update cpy-cli major version
mphstudios Feb 15, 2024
315e24a
Update del-cli minor version
mphstudios Feb 15, 2024
e87e625
Update chalk major version
mphstudios Feb 15, 2024
589b58e
Update markdown-it and plugins to ESM versions
mphstudios Feb 15, 2024
0f26bae
Update eslint and prettier minor versions
mphstudios Feb 15, 2024
c3801e2
Update jsdom major version
mphstudios Feb 15, 2024
f928449
Update sass minor version
mphstudios Feb 15, 2024
a1e94ad
Update rollup-plugin-copy minor version
mphstudios Feb 15, 2024
dee3170
Update liquidjs and liquid-args
mphstudios Feb 15, 2024
60c32d0
Update lit major version
mphstudios Feb 15, 2024
ca8a62a
Update fs-extra minor version
mphstudios Feb 15, 2024
47b264d
Update to core-js v3
mphstudios Feb 15, 2024
71ec260
Update markdown-it-anchor patch version
mphstudios Feb 15, 2024
898b00e
Fix eleventy@3 cli module extension
mphstudios Feb 15, 2024
7b4e5bc
Fix import statements by adding js file extensions
mphstudios Feb 16, 2024
3d1eaef
Update eslint configuration
mphstudios Feb 16, 2024
eeb3763
Update ESlint configuration
mphstudios Apr 23, 2024
7424c43
Update 11ty v3 release
mphstudios Oct 11, 2024
81c4584
Install the Eleventy v2 to v3 helper plugin
mphstudios Oct 12, 2024
086ac6f
Refactoring for Eleventy v3 Configuration API
mphstudios Oct 12, 2024
5d39cd3
Merge branch 'main' into deps/eleventy-v3
mphstudios Dec 19, 2024
fe51b13
Basic eleventy v3 MVP
cbutcosk Jan 10, 2025
8cdba1e
Use citeproc directly in CSL->text citation transform (fixes DEV-19476)
cbutcosk Jan 27, 2025
6f87509
Revert iiif/builder to iiif-builder (resolves DEV-19475)
cbutcosk Jan 27, 2025
7643f4a
Correct iiif-builder import syntax
cbutcosk Jan 27, 2025
219ac46
Fix epub path resolutions and asset bundling path math
cbutcosk Jan 27, 2025
87c19ff
Add changelog for release
cbutcosk Jan 27, 2025
a5430be
Auto-generated lint fixes
cbutcosk Jan 29, 2025
a31748b
Remaining lint fixes
cbutcosk Jan 29, 2025
73a1dbf
Restore minified soundcloud w/ disabled eslint
cbutcosk Jan 29, 2025
01c4e32
Revert unused var removal and silence lint warning
cbutcosk Jan 29, 2025
c6faa30
Update changelog heading
mphstudios Jan 29, 2025
a8a7112
Update changelog for breaking changes
mphstudios Jan 29, 2025
c340baa
Amend previous changelog edit
mphstudios Jan 29, 2025
7a611ed
Silence stray epub transform log
cbutcosk Jan 29, 2025
6cf15e0
Merge pull request #991 from thegetty/fix/eslint-first-extended-run-f…
cbutcosk Jan 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions _tests/pdf.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const test = require('node:test');

import { execa } from 'execa';
import { PDFDocument } from 'pdf-lib';
import { execa } from 'execa';
import test from 'node:test';

// Start a new default publication, build it, and make the pdf
var { stderr, stdout } = await execa("npx",["quire","new", "--quire-path", "$(pwd)/packages/11ty", "test-pub"])
Expand Down
227 changes: 136 additions & 91 deletions packages/11ty/.eleventy.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,68 @@
require('module-alias/register')

const copy = require('rollup-plugin-copy')
const fs = require('fs-extra')
const packageJSON = require('./package.json');
const path = require('path')
const scss = require('rollup-plugin-scss')

const chalkFactory = require('~lib/chalk')
import fs from 'fs-extra'
import path from 'node:path'

/**
* Quire features are implemented as Eleventy plugins
* Eleventy plugins
*/
const {
import {
EleventyHtmlBasePlugin,
IdAttributePlugin,
InputPathToUrlTransformPlugin,
EleventyRenderPlugin
} = require('@11ty/eleventy')
const citationsPlugin = require('~plugins/citations')
const collectionsPlugin = require('~plugins/collections')
const componentsPlugin = require('~plugins/components')
const dataExtensionsPlugin = require('~plugins/dataExtensions')
const directoryOutputPlugin = require('@11ty/eleventy-plugin-directory-output')
const figuresPlugin = require('~plugins/figures')
const filtersPlugin = require('~plugins/filters')
const frontmatterPlugin = require('~plugins/frontmatter')
const globalDataPlugin = require('~plugins/globalData')
const i18nPlugin = require('~plugins/i18n')
const lintersPlugin = require('~plugins/linters')
const markdownPlugin = require('~plugins/markdown')
const navigationPlugin = require('@11ty/eleventy-navigation')
const pluginWebc = require('@11ty/eleventy-plugin-webc')
const searchPlugin = require('~plugins/search')
const shortcodesPlugin = require('~plugins/shortcodes')
const syntaxHighlightPlugin = require('@11ty/eleventy-plugin-syntaxhighlight')
const transformsPlugin = require('~plugins/transforms')
const vitePlugin = require('~plugins/vite')
} from '@11ty/eleventy'
// import { eleventyImageTransformPlugin } from '@11ty/eleventy-img'
import directoryOutputPlugin from '@11ty/eleventy-plugin-directory-output'
import navigationPlugin from '@11ty/eleventy-navigation'
import pluginWebc from '@11ty/eleventy-plugin-webc'
import syntaxHighlightPlugin from '@11ty/eleventy-plugin-syntaxhighlight'
import UpgradeHelper from '@11ty/eleventy-upgrade-help'

/**
* Quire plugins for Eleventy
* dynamic import of the default export from local plugins modules
*/
// const plugins =
// fs.readdir('_plugins', { withFileTypes: true }, (error, entries) => {
// entries.forEach((entry) => {
// if (entry.isDirectory()) {
// const { default: plugin } = await import(`./plugins/${entry.name}`)
// eleventyConfig.addPlugin(plugin, collections)
// }
// })
// })
import citationsPlugin from '#plugins/citations/index.js'
import collectionsPlugin from '#plugins/collections/index.js'
import componentsPlugin from '#plugins/components/index.js'
import dataExtensionsPlugin from '#plugins/dataExtensions/index.js'
import figuresPlugin from '#plugins/figures/index.js'
import filtersPlugin from '#plugins/filters/index.js'
import frontmatterPlugin from '#plugins/frontmatter/index.js'
import globalDataPlugin from '#plugins/globalData/index.js'
import i18nPlugin from '#plugins/i18n/index.js'
import lintersPlugin from '#plugins/linters/index.js'
import markdownPlugin from '#plugins/markdown/index.js'
import searchPlugin from '#plugins/search/index.js'
import shortcodesPlugin from '#plugins/shortcodes/index.js'
import transformsPlugin from '#plugins/transforms/index.js'
import vitePlugin from '#plugins/vite/index.js'

/**
* Application modules
*/
import chalkFactory from '#lib/chalk/index.js'

// Read package.json manually for now, see: https://github.com/11ty/eleventy/issues/3128
// When issue merged, use: import packageJSON from './package.json' with { type: 'json' };
const packageJSON = JSON.parse(
(await fs.readFile(new URL('package.json', import.meta.url))).toString()
)

// eslint-disable-next-line no-unused-vars
const { error } = chalkFactory('eleventy config')

const inputDir = process.env.ELEVENTY_INPUT || 'content'
const outputDir = process.env.ELEVENTY_OUTPUT || '_site'
const publicDir = process.env.ELEVENTY_ENV === 'production' ? 'public' : false // publicDir should be set explicitly to false in development
const publicDir = process.env.ELEVENTY_ENV === 'production' ? 'public' : false // publicDir should be set explicitly to false in development

/**
* Eleventy configuration
Expand All @@ -48,7 +71,44 @@ const publicDir = process.env.ELEVENTY_ENV === 'production' ? 'public' : false /
* @param {Object} base eleventy configuration
* @return {Object} A modified eleventy configuation
*/
module.exports = function(eleventyConfig) {
export default async function (eleventyConfig) {
/**
* Eleventy v2 to v3 upgrade helper
* @see https://www.11ty.dev/docs/plugins/upgrade-help/
*/
eleventyConfig.addPlugin(UpgradeHelper)

const dataDir = process.env.ELEVENTY_DATA || '_computed'
const includesDir = process.env.ELEVENTY_INCLUDES || path.join('..', '_includes')
const layoutsDir = process.env.ELEVENTY_LAYOUTS || path.join('..', '_layouts')

// ⚠️ input and output dirs are _relative_ to the `.eleventy.js` module
eleventyConfig.setInputDirectory(inputDir)
eleventyConfig.setOutputDirectory(outputDir)
// ⚠️ the following directories are _relative_ to the `input` directory
eleventyConfig.setDataDirectory(dataDir)
eleventyConfig.setIncludesDirectory(includesDir)
eleventyConfig.setLayoutsDirectory(layoutsDir)

/**
* All of the following template formats support universal shortcodes.
*
* Nota bene:
* Markdown files are pre-processed as Liquid templates by default. This
* means that shortcodes available in Liquid templates are also available
* in Markdown files. Likewise, if you change the template engine for
* Markdown files, the shortcodes available for that templating language
* will also be available in Markdown files.
* @see {@link https://www.11ty.dev/docs/config/#template-formats}
*/
eleventyConfig.setTemplateFormats([
'11ty.js', // JavaScript
'html', // HTML
'liquid', // Liquid
'md', // Markdown
'njk' // Nunjucks
])

/**
* Override addPassthroughCopy to use _absolute_ system paths.
* @see https://www.11ty.dev/docs/copy/#passthrough-file-copy
Expand Down Expand Up @@ -116,7 +176,17 @@ module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(EleventyHtmlBasePlugin)

/**
* Plugins are loaded in this order:
* @see https://www.11ty.dev/docs/plugins/id-attribute/
*/
eleventyConfig.addPlugin(IdAttributePlugin)

/**
* @see https://www.11ty.dev/docs/plugins/inputpath-to-url/
*/
eleventyConfig.addPlugin(InputPathToUrlTransformPlugin)

/**
* Plugins are loaded in this order:
* 1) immediately invoked
* 2) addPlugin statements
* Plugins that mutate globalData must be added before other plugins
Expand Down Expand Up @@ -171,11 +241,33 @@ module.exports = function(eleventyConfig) {
* @property {Boolean} useTransform - Use WebC transform to process all HTML output
*/
eleventyConfig.addPlugin(pluginWebc, {
components: '_includes/components/**/*.webc',
components: [
'_includes/components/**/*.webc',
'npm:@11ty/eleventy-img/*.webc'
],
transformData: {},
useTransform: false,
useTransform: false
})

/**
* Configure the Eleventy Image plugin
* @see https://www.11ty.dev/docs/plugins/image/
*/
// eleventyConfig.addPlugin(eleventyImageTransformPlugin, {
// defaultAttributes: {
// decoding: 'async',
// loading: 'lazy'
// },
// filenameFormat: (id, src, width, format, options) => {
// const extension = path.extname(src)
// const name = path.basename(src, extension)
// return `${name}-${width}w.${format}`
// },
// formats: ['jpeg'],
// outputDir: '.',
// urlPath: '/img/'
// })

/**
* Register a plugin to run linters on input templates
* Nota bene: linters are run *before* applying layouts
Expand Down Expand Up @@ -225,59 +317,12 @@ module.exports = function(eleventyConfig) {
eleventyConfig.watchIgnores.add('_pdf')
eleventyConfig.watchIgnores.add('_temp')

const { pathname: pathPrefix } = globalData.publication
return {
/**
* @see {@link https://www.11ty.dev/docs/config/#configuration-options}
*/
dir: {
// ⚠️ input and output dirs are _relative_ to the `.eleventy.js` module
input: inputDir,
output: outputDir,
// ⚠️ the following directories are _relative_ to the `input` directory
data: process.env.ELEVENTY_DATA || '_computed',
includes: process.env.ELEVENTY_INCLUDES || path.join('..', '_includes'),
layouts: process.env.ELEVENTY_LAYOUTS || path.join('..', '_layouts'),
},
/**
* The default global template engine to pre-process HTML files.
* Use false to avoid pre-processing and passthrough copy the content (HTML is not transformed, so technically this could be any plaintext).
* @see {@link https://www.11ty.dev/docs/config/#default-template-engine-for-html-files}
*/
htmlTemplateEngine: 'liquid',
/**
* Suffix for template and directory specific data files
* @example '.data' will search for `*.data.js` and `*.data.json` data files.
* @see {@link https://www.11ty.dev/docs/data-template-dir/ Template and Directory Specific Data Files}
*/
jsDataFileSuffix: '.data',
/**
* The default global template engine to pre-process markdown files.
* Use false to avoid pre-processing and only transform markdown.
* @see {@link https://www.11ty.dev/docs/config/#default-template-engine-for-markdown-files}
*/
markdownTemplateEngine: 'liquid',
/**
* @see {@link https://www.11ty.dev/docs/config/#deploy-to-a-subdirectory-with-a-path-prefix}
*/
pathPrefix,
/**
* All of the following template formats support universal shortcodes.
*
* Nota bene:
* Markdown files are pre-processed as Liquid templates by default. This
* means that shortcodes available in Liquid templates are also available
* in Markdown files. Likewise, if you change the template engine for
* Markdown files, the shortcodes available for that templating language
* will also be available in Markdown files.
* @see {@link https://www.11ty.dev/docs/config/#template-formats}
*/
templateFormats: [
'11ty.js', // JavaScript
'hbs', // Handlebars
'liquid', // Liquid
'md', // Markdown
'njk', // Nunjucks
]
}
/**
* Suffix for template and directory specific data files
* @example '.data' will search for `*.data.js` and `*.data.json` data files
* @see https://www.11ty.dev/docs/config/#change-base-file-name-for-data-files
* @see https://www.11ty.dev/docs/config/#change-file-suffix-for-data-files
*/
eleventyConfig.setDataFileBaseName('index')
eleventyConfig.setDataFileSuffixes(['.data', ''])
}
34 changes: 0 additions & 34 deletions packages/11ty/.eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion packages/11ty/.node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.16.0
21.1.0
9 changes: 9 additions & 0 deletions packages/11ty/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ Changelog entries are classified using the following labels:
- `Fixed`: for any bug fixes
- `Removed`: for deprecated features removed in this release

## [unreleased]

### Bumped

- Update dependency pins for `@11ty/eleventy`, `@11ty/eleventy-plugin-vite` to support Eleventy v3

### Breaking

This release is updates the *major* version of `eleventy`, which requires using ECMAScript module (ESM) syntax for JavaScript code. Specifically, ESM `import` statements to use other modules and the `import.meta.url` property for a module's file path from within that module. For most Quire users this update should be transparent. For publications that have customized the quire code or import packages that are not already in the publication's package dependency tree changes may be needed to address ESM conformance to the custom modules.
## [1.0.0-rc.22]

### Changed
Expand Down
6 changes: 3 additions & 3 deletions packages/11ty/_includes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ The `data` property contains the final data from the [Eleventy data cascade](htt

#### In an `11ty.js` `_include`
```javascript
const { html } = require('common-tags')
import { html } from 'common-tags'

module.exports = function(eleventyConfig, params) {
export default function(eleventyConfig, params) {
const { publication } = params
const siteTitle = eleventyConfig.getFilter('siteTitle')

Expand All @@ -47,7 +47,7 @@ module.exports = function(eleventyConfig, params) {

#### In an `11ty.js` `_layout`
```javascript
const { html } = require('common-tags')
import { html } from 'common-tags'

exports.data = {
layout: 'base'
Expand Down
4 changes: 2 additions & 2 deletions packages/11ty/_includes/components/abstract.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const { html } = require('~lib/common-tags')
import { html } from '#lib/common-tags/index.js'

/**
* Publication abstract
* @param {Object} eleventyConfig
*/
module.exports = function(eleventyConfig) {
export default function (eleventyConfig) {
const markdownify = eleventyConfig.getFilter('markdownify')
return function (params) {
const { abstract } = params
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const { html } = require('~lib/common-tags')
import { html } from '#lib/common-tags/index.js'

/**
* @param {Object} eleventyConfig
* @returns Global Accordion Controls Shortcode
*/
module.exports = function(eleventyConfig) {
export default function (eleventyConfig) {
const { collapseText, expandText } = eleventyConfig.globalData.config.accordion.globalControls

/**
* @return {String} html markup for global accordion controls
*/
return function() {
return function () {
return html`
<div class="global-accordion-controls" data-outputs-exclude="pdf,epub">
<button class="global-accordion-expand-all visually-hidden">${expandText}</button>
Expand Down
Loading