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

outputPath.endsWith check fails with permalink: false #103

Closed
SergeyRe opened this issue Sep 25, 2021 · 1 comment · Fixed by #107
Closed

outputPath.endsWith check fails with permalink: false #103

SergeyRe opened this issue Sep 25, 2021 · 1 comment · Fixed by #107

Comments

@SergeyRe
Copy link

Problem specific to some plugings ( incl. amp-plugin) due to not taking into accout next moment described here
page.outputPath and page.url can sometimes be false, not strings
More details and discussion of this issue
Sure this plugin have to be modified

@thedalewilliams
Copy link

I had this issue as well while using pagination and having permalink false in the front matter.

Today I used patch-package to patch @ampproject/eleventy-plugin-amp@0.5.7 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/@ampproject/eleventy-plugin-amp/src/helpers/AmpConfig.js b/node_modules/@ampproject/eleventy-plugin-amp/src/helpers/AmpConfig.js
index 3b572e1..a3eb25d 100644
--- a/node_modules/@ampproject/eleventy-plugin-amp/src/helpers/AmpConfig.js
+++ b/node_modules/@ampproject/eleventy-plugin-amp/src/helpers/AmpConfig.js
@@ -30,7 +30,7 @@ const AmpConfig = (providedOptions) => {
     throw new Error(`filter needs to be a valid RegExp, provided : ${options.filter}`);
   }
 
-  options.isAmp = (path) => path.endsWith('.html') && options.filter.test(path);
+  options.isAmp = (path) => path && path.endsWith('.html') && options.filter.test(path);
 
   if (providedOptions.optimizeImages !== false && !providedOptions.imageOptimizer) {
     options.imageOptimizer = ImageOptimizer.create(options);

This issue body was partially generated by patch-package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants