formate eleventy.js properly
This commit is contained in:
		
							
								
								
									
										54
									
								
								.eleventy.js
									
									
									
									
									
								
							
							
						
						
									
										54
									
								
								.eleventy.js
									
									
									
									
									
								
							@ -17,7 +17,7 @@ module.exports = function (eleventyConfig) {
 | 
			
		||||
    collectionApi.getAll().map(item => {
 | 
			
		||||
      if (item.data.tags) { // handle pages that don't have tags
 | 
			
		||||
        item.data.tags.map(tag => {
 | 
			
		||||
          if (tag != "post"){
 | 
			
		||||
          if (tag != "post") {
 | 
			
		||||
            tagsList.add(tag)
 | 
			
		||||
          }
 | 
			
		||||
        })
 | 
			
		||||
@ -40,42 +40,42 @@ module.exports = function (eleventyConfig) {
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  // clean and inline all css files
 | 
			
		||||
  eleventyConfig.addFilter("cssmin", function(code) {
 | 
			
		||||
  eleventyConfig.addFilter("cssmin", function (code) {
 | 
			
		||||
    return new cleancss({}).minify(code).styles;
 | 
			
		||||
  });
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  // // the below three configs allow for excluding files from builds using draft: true
 | 
			
		||||
  // // https://www.11ty.dev/docs/quicktips/draft-posts/ 
 | 
			
		||||
  // When `permalink` is false, the file is not written to disk
 | 
			
		||||
	eleventyConfig.addGlobalData("eleventyComputed.permalink", function() {
 | 
			
		||||
		return (data) => {
 | 
			
		||||
			// Always skip during non-watch/serve builds
 | 
			
		||||
			if(data.draft && !process.env.BUILD_DRAFTS) {
 | 
			
		||||
				return false;
 | 
			
		||||
			}
 | 
			
		||||
  eleventyConfig.addGlobalData("eleventyComputed.permalink", function () {
 | 
			
		||||
    return (data) => {
 | 
			
		||||
      // Always skip during non-watch/serve builds
 | 
			
		||||
      if (data.draft && !process.env.BUILD_DRAFTS) {
 | 
			
		||||
        return false;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
			return data.permalink;
 | 
			
		||||
		}
 | 
			
		||||
	});
 | 
			
		||||
      return data.permalink;
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  // When `eleventyExcludeFromCollections` is true, the file is not included in any collections
 | 
			
		||||
	eleventyConfig.addGlobalData("eleventyComputed.eleventyExcludeFromCollections", function() {
 | 
			
		||||
		return (data) => {
 | 
			
		||||
			// Always exclude from non-watch/serve builds
 | 
			
		||||
			if(data.draft && !process.env.BUILD_DRAFTS) {
 | 
			
		||||
				return true;
 | 
			
		||||
			}
 | 
			
		||||
  eleventyConfig.addGlobalData("eleventyComputed.eleventyExcludeFromCollections", function () {
 | 
			
		||||
    return (data) => {
 | 
			
		||||
      // Always exclude from non-watch/serve builds
 | 
			
		||||
      if (data.draft && !process.env.BUILD_DRAFTS) {
 | 
			
		||||
        return true;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
			return data.eleventyExcludeFromCollections;
 | 
			
		||||
		}
 | 
			
		||||
	});
 | 
			
		||||
      return data.eleventyExcludeFromCollections;
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
	eleventyConfig.on("eleventy.before", ({runMode}) => {
 | 
			
		||||
		// Set the environment variable
 | 
			
		||||
		if(runMode === "serve" || runMode === "watch") {
 | 
			
		||||
			process.env.BUILD_DRAFTS = true;
 | 
			
		||||
		}
 | 
			
		||||
	});
 | 
			
		||||
  eleventyConfig.on("eleventy.before", ({ runMode }) => {
 | 
			
		||||
    // Set the environment variable
 | 
			
		||||
    if (runMode === "serve" || runMode === "watch") {
 | 
			
		||||
      process.env.BUILD_DRAFTS = true;
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  return {
 | 
			
		||||
    passthroughFileCopy: true,
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user