Skip to content

Commit

Permalink
Passthrough copy, filters, ignores ESM docs 11ty/eleventy#836
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Sep 24, 2024
1 parent 2b6858a commit 0119cae
Show file tree
Hide file tree
Showing 19 changed files with 588 additions and 207 deletions.
33 changes: 33 additions & 0 deletions src/_includes/snippets/config/ignores-nodemod.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{%- set tabid = "ignoresnodemod" %}
<div class="codetitle codetitle-right-md">eleventy.config.js</div>
<is-land on:visible import="/js/seven-minute-tabs.js">
<seven-minute-tabs class="tabs-flush" persist sync>
{% renderFile "./src/_includes/syntax-chooser-tablist.11ty.js", {id: tabid, only: "jsesm,jscjs"} %}
<div id="{{ tabid }}-jsesm" role="tabpanel">

```js
export default function (eleventyConfig) {
// in Eleventy 2.0
eleventyConfig.ignores.delete("**/node_modules/**");

// in Eleventy 1.0
eleventyConfig.ignores.delete("node_modules/**");
};
```

</div>
<div id="{{ tabid }}-jscjs" role="tabpanel">

```js
module.exports = function (eleventyConfig) {
// in Eleventy 2.0
eleventyConfig.ignores.delete("**/node_modules/**");

// in Eleventy 1.0
eleventyConfig.ignores.delete("node_modules/**");
};
```

</div>
</seven-minute-tabs>
</is-land>
25 changes: 25 additions & 0 deletions src/_includes/snippets/config/ignores-optout.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{%- set tabid = "ignoresoptout" %}
<div class="codetitle codetitle-right-md">eleventy.config.js</div>
<is-land on:visible import="/js/seven-minute-tabs.js">
<seven-minute-tabs class="tabs-flush" persist sync>
{% renderFile "./src/_includes/syntax-chooser-tablist.11ty.js", {id: tabid, only: "jsesm,jscjs"} %}
<div id="{{ tabid }}-jsesm" role="tabpanel">

```js
export default function (eleventyConfig) {
eleventyConfig.setUseGitIgnore(false);
};
```

</div>
<div id="{{ tabid }}-jscjs" role="tabpanel">

```js
module.exports = function (eleventyConfig) {
eleventyConfig.setUseGitIgnore(false);
};
```

</div>
</seven-minute-tabs>
</is-land>
27 changes: 27 additions & 0 deletions src/_includes/snippets/config/ignores.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{%- set tabid = "ignores" %}
<div class="codetitle codetitle-right-md">eleventy.config.js</div>
<is-land on:visible import="/js/seven-minute-tabs.js">
<seven-minute-tabs class="tabs-flush" persist sync>
{% renderFile "./src/_includes/syntax-chooser-tablist.11ty.js", {id: tabid, only: "jsesm,jscjs"} %}
<div id="{{ tabid }}-jsesm" role="tabpanel">

```js
export default function (eleventyConfig) {
eleventyConfig.ignores.add("README.md");
eleventyConfig.ignores.delete("README.md");
};
```

</div>
<div id="{{ tabid }}-jscjs" role="tabpanel">

```js
module.exports = function (eleventyConfig) {
eleventyConfig.ignores.add("README.md");
eleventyConfig.ignores.delete("README.md");
};
```

</div>
</seven-minute-tabs>
</is-land>
37 changes: 37 additions & 0 deletions src/_includes/snippets/copy/advanced.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{%- set tabid = "copyadv" %}
<div class="codetitle codetitle-right-md">eleventy.config.js</div>
<is-land on:visible import="/js/seven-minute-tabs.js">
<seven-minute-tabs class="tabs-flush" persist sync>
{% renderFile "./src/_includes/syntax-chooser-tablist.11ty.js", {id: tabid, only: "jsesm,jscjs"} %}
<div id="{{ tabid }}-jsesm" role="tabpanel">

```js
export default function (eleventyConfig) {
eleventyConfig.addPassthroughCopy("img", {
expand: true, // expand symbolic links
});

eleventyConfig.addPassthroughCopy({ img: "subfolder/img" }, {
debug: true, // log debug information
});
};
```

</div>
<div id="{{ tabid }}-jscjs" role="tabpanel">

```js
module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy("img", {
expand: true, // expand symbolic links
});

eleventyConfig.addPassthroughCopy({ img: "subfolder/img" }, {
debug: true, // log debug information
});
};
```

</div>
</seven-minute-tabs>
</is-land>
27 changes: 27 additions & 0 deletions src/_includes/snippets/copy/copy-emulate.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{%- set tabid = "copyemu" %}
<div class="codetitle codetitle-right-md">eleventy.config.js</div>
<is-land on:visible import="/js/seven-minute-tabs.js">
<seven-minute-tabs class="tabs-flush" persist sync>
{% renderFile "./src/_includes/syntax-chooser-tablist.11ty.js", {id: tabid, only: "jsesm,jscjs"} %}
<div id="{{ tabid }}-jsesm" role="tabpanel">

```js
export default function (eleventyConfig) {
// the default is "copy"
eleventyConfig.setServerPassthroughCopyBehavior("passthrough");
};
```

</div>
<div id="{{ tabid }}-jscjs" role="tabpanel">

```js
module.exports = function (eleventyConfig) {
// the default is "copy"
eleventyConfig.setServerPassthroughCopyBehavior("passthrough");
};
```

</div>
</seven-minute-tabs>
</is-land>
31 changes: 31 additions & 0 deletions src/_includes/snippets/copy/copy-ext.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{%- set tabid = "copyext" %}
<div class="codetitle codetitle-right-md">eleventy.config.js</div>
<is-land on:visible import="/js/seven-minute-tabs.js">
<seven-minute-tabs class="tabs-flush" persist sync>
{% renderFile "./src/_includes/syntax-chooser-tablist.11ty.js", {id: tabid, only: "jsesm,jscjs"} %}
<div id="{{ tabid }}-jsesm" role="tabpanel">

```js
export default function (eleventyConfig) {
eleventyConfig.setTemplateFormats([
"md",
"css", // css is not yet a recognized template extension in Eleventy
]);
};
```

</div>
<div id="{{ tabid }}-jscjs" role="tabpanel">

```js
module.exports = function (eleventyConfig) {
eleventyConfig.setTemplateFormats([
"md",
"css", // css is not yet a recognized template extension in Eleventy
]);
};
```

</div>
</seven-minute-tabs>
</is-land>
27 changes: 27 additions & 0 deletions src/_includes/snippets/copy/copy-globs.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{%- set tabid = "copyglobs" %}
<div class="codetitle codetitle-right-md">eleventy.config.js</div>
<is-land on:visible import="/js/seven-minute-tabs.js">
<seven-minute-tabs class="tabs-flush" persist sync>
{% renderFile "./src/_includes/syntax-chooser-tablist.11ty.js", {id: tabid, only: "jsesm,jscjs"} %}
<div id="{{ tabid }}-jsesm" role="tabpanel">

```js
export default function (eleventyConfig) {
// Find and copy any `jpg` files, maintaining directory structure.
eleventyConfig.addPassthroughCopy("**/*.jpg");
};
```

</div>
<div id="{{ tabid }}-jscjs" role="tabpanel">

```js
module.exports = function (eleventyConfig) {
// Find and copy any `jpg` files, maintaining directory structure.
eleventyConfig.addPassthroughCopy("**/*.jpg");
};
```

</div>
</seven-minute-tabs>
</is-land>
33 changes: 33 additions & 0 deletions src/_includes/snippets/copy/copy-input.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{%- set tabid = "copyinput" %}
<div class="codetitle codetitle-right-md">eleventy.config.js</div>
<is-land on:visible import="/js/seven-minute-tabs.js">
<seven-minute-tabs class="tabs-flush" persist sync>
{% renderFile "./src/_includes/syntax-chooser-tablist.11ty.js", {id: tabid, only: "jsesm,jscjs"} %}
<div id="{{ tabid }}-jsesm" role="tabpanel">

```js
export default function (eleventyConfig) {
// Input directory: src
// Output directory: _site

// The following copies to `_site/img`
eleventyConfig.addPassthroughCopy("src/img");
};
```

</div>
<div id="{{ tabid }}-jscjs" role="tabpanel">

```js
module.exports = function (eleventyConfig) {
// Input directory: src
// Output directory: _site

// The following copies to `_site/img`
eleventyConfig.addPassthroughCopy("src/img");
};
```

</div>
</seven-minute-tabs>
</is-land>
33 changes: 33 additions & 0 deletions src/_includes/snippets/copy/copy-mix.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{%- set tabid = "copymix" %}
<div class="codetitle codetitle-right-md">eleventy.config.js</div>
<is-land on:visible import="/js/seven-minute-tabs.js">
<seven-minute-tabs class="tabs-flush" persist sync>
{% renderFile "./src/_includes/syntax-chooser-tablist.11ty.js", {id: tabid, only: "jsesm,jscjs"} %}
<div id="{{ tabid }}-jsesm" role="tabpanel">

```js
export default function (eleventyConfig) {
// Output directory: _site

// Find and copy any `jpg` files in any folder to _site/img
// Does not keep the same directory structure.
eleventyConfig.addPassthroughCopy({ "**/*.jpg": "img" });
};
```

</div>
<div id="{{ tabid }}-jscjs" role="tabpanel">

```js
module.exports = function (eleventyConfig) {
// Output directory: _site

// Find and copy any `jpg` files in any folder to _site/img
// Does not keep the same directory structure.
eleventyConfig.addPassthroughCopy({ "**/*.jpg": "img" });
};
```

</div>
</seven-minute-tabs>
</is-land>
45 changes: 45 additions & 0 deletions src/_includes/snippets/copy/copy-output.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{%- set tabid = "copyout" %}
<div class="codetitle codetitle-right-md">eleventy.config.js</div>
<is-land on:visible import="/js/seven-minute-tabs.js">
<seven-minute-tabs class="tabs-flush" persist sync>
{% renderFile "./src/_includes/syntax-chooser-tablist.11ty.js", {id: tabid, only: "jsesm,jscjs"} %}
<div id="{{ tabid }}-jsesm" role="tabpanel">

```js
export default function (eleventyConfig) {
// Input directory: src
// Output directory: _site

// Copy `img/` to `_site/subfolder/img`
eleventyConfig.addPassthroughCopy({ img: "subfolder/img" });

// Copy `src/img/` to `_site/subfolder/img`
eleventyConfig.addPassthroughCopy({ "src/img": "subfolder/img" });

// Copy `random-folder/img/` to `_site/subfolder/img`
eleventyConfig.addPassthroughCopy({ "random-folder/img": "subfolder/img" });
};
```

</div>
<div id="{{ tabid }}-jscjs" role="tabpanel">

```js
module.exports = function (eleventyConfig) {
// Input directory: src
// Output directory: _site

// Copy `img/` to `_site/subfolder/img`
eleventyConfig.addPassthroughCopy({ img: "subfolder/img" });

// Copy `src/img/` to `_site/subfolder/img`
eleventyConfig.addPassthroughCopy({ "src/img": "subfolder/img" });

// Copy `random-folder/img/` to `_site/subfolder/img`
eleventyConfig.addPassthroughCopy({ "random-folder/img": "subfolder/img" });
};
```

</div>
</seven-minute-tabs>
</is-land>
47 changes: 47 additions & 0 deletions src/_includes/snippets/copy/copy.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{%- set tabid = "copy" %}
<div class="codetitle codetitle-right-md">eleventy.config.js</div>
<is-land on:visible import="/js/seven-minute-tabs.js">
<seven-minute-tabs class="tabs-flush" persist sync>
{% renderFile "./src/_includes/syntax-chooser-tablist.11ty.js", {id: tabid, only: "jsesm,jscjs"} %}
<div id="{{ tabid }}-jsesm" role="tabpanel">

```js
export default function (eleventyConfig) {
// Output directory: _site

// Copy `img/` to `_site/img`
eleventyConfig.addPassthroughCopy("img");

// Copy `css/fonts/` to `_site/css/fonts`
// Keeps the same directory structure.
eleventyConfig.addPassthroughCopy("css/fonts");

// Copy any .jpg file to `_site`, via Glob pattern
// Keeps the same directory structure.
eleventyConfig.addPassthroughCopy("**/*.jpg");
};
```

</div>
<div id="{{ tabid }}-jscjs" role="tabpanel">

```js
module.exports = function (eleventyConfig) {
// Output directory: _site

// Copy `img/` to `_site/img`
eleventyConfig.addPassthroughCopy("img");

// Copy `css/fonts/` to `_site/css/fonts`
// Keeps the same directory structure.
eleventyConfig.addPassthroughCopy("css/fonts");

// Copy any .jpg file to `_site`, via Glob pattern
// Keeps the same directory structure.
eleventyConfig.addPassthroughCopy("**/*.jpg");
};
```

</div>
</seven-minute-tabs>
</is-land>
Loading

0 comments on commit 0119cae

Please sign in to comment.