✨ feat: Add noreferrer plugin
This commit is contained in:
parent
2074751fab
commit
1be374c912
3 changed files with 72 additions and 46 deletions
97
.eleventy.js
97
.eleventy.js
|
@ -1,59 +1,64 @@
|
||||||
const esbuild = require('esbuild')
|
const esbuild = require('esbuild')
|
||||||
|
|
||||||
module.exports = function (eleventyConfig) {
|
module.exports = function (eleventyConfig) {
|
||||||
// Process SCSS
|
// Process SCSS
|
||||||
eleventyConfig.addPlugin(require('eleventy-sass'), {
|
eleventyConfig.addPlugin(require('eleventy-sass'), {
|
||||||
postcss: require('postcss')([
|
postcss: require('postcss')([
|
||||||
require('postcss-preset-env'),
|
require('postcss-preset-env'),
|
||||||
require('cssnano'),
|
require('cssnano'),
|
||||||
]),
|
]),
|
||||||
})
|
})
|
||||||
|
|
||||||
// Copy CSS assets
|
// Add noopener to links
|
||||||
eleventyConfig.addPassthroughCopy('src/style/assets')
|
eleventyConfig.addPlugin(require('eleventy-plugin-automatic-noopener'), {
|
||||||
|
noreferrer: true,
|
||||||
|
})
|
||||||
|
|
||||||
// Copy collections & links
|
// Copy CSS assets
|
||||||
eleventyConfig.addPassthroughCopy('src/collections/images/**/*')
|
eleventyConfig.addPassthroughCopy('src/style/assets')
|
||||||
eleventyConfig.addPassthroughCopy('src/images')
|
|
||||||
|
|
||||||
// Process JS
|
// Copy collections & links
|
||||||
eleventyConfig.addTemplateFormats('js')
|
eleventyConfig.addPassthroughCopy('src/collections/images/**/*')
|
||||||
eleventyConfig.addExtension('js', {
|
eleventyConfig.addPassthroughCopy('src/images')
|
||||||
outputFileExtension: 'js',
|
|
||||||
compile: async (content, path) => {
|
|
||||||
if (path !== './src/js/main.js') {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return async () => {
|
// Process JS
|
||||||
const output = await esbuild.build({
|
eleventyConfig.addTemplateFormats('js')
|
||||||
target: 'es2020',
|
eleventyConfig.addExtension('js', {
|
||||||
entryPoints: [path],
|
outputFileExtension: 'js',
|
||||||
minify: true,
|
compile: async (content, path) => {
|
||||||
bundle: true,
|
if (path !== './src/js/main.js') {
|
||||||
write: false,
|
return
|
||||||
})
|
}
|
||||||
|
|
||||||
return output.outputFiles[0].text
|
return async () => {
|
||||||
}
|
const output = await esbuild.build({
|
||||||
},
|
target: 'es2020',
|
||||||
})
|
entryPoints: [path],
|
||||||
|
minify: true,
|
||||||
|
bundle: true,
|
||||||
|
write: false,
|
||||||
|
})
|
||||||
|
|
||||||
// Convert img filename to alt text
|
return output.outputFiles[0].text
|
||||||
eleventyConfig.addFilter('toAlt', (text) => {
|
}
|
||||||
const basename = text.split('.')
|
},
|
||||||
return basename[0].replace(/-/g, ' ')
|
})
|
||||||
})
|
|
||||||
|
|
||||||
// Convert diary date path to slug
|
// Convert img filename to alt text
|
||||||
eleventyConfig.addFilter('datePathSlugify', (path) => {
|
eleventyConfig.addFilter('toAlt', (text) => {
|
||||||
const folders = path.split('/')
|
const basename = text.split('.')
|
||||||
const file = folders.pop().split('.')
|
return basename[0].replace(/-/g, ' ')
|
||||||
return `${folders[3]}/${folders[4]}/${file[0]}`
|
})
|
||||||
})
|
|
||||||
|
|
||||||
// RSS
|
// Convert diary date path to slug
|
||||||
eleventyConfig.addPlugin(require('@11ty/eleventy-plugin-rss'))
|
eleventyConfig.addFilter('datePathSlugify', (path) => {
|
||||||
|
const folders = path.split('/')
|
||||||
|
const file = folders.pop().split('.')
|
||||||
|
return `${folders[3]}/${folders[4]}/${file[0]}`
|
||||||
|
})
|
||||||
|
|
||||||
return {dir: {input: 'src', output: 'dist'}}
|
// RSS
|
||||||
|
eleventyConfig.addPlugin(require('@11ty/eleventy-plugin-rss'))
|
||||||
|
|
||||||
|
return {dir: {input: 'src', output: 'dist'}}
|
||||||
}
|
}
|
||||||
|
|
20
package-lock.json
generated
20
package-lock.json
generated
|
@ -11,6 +11,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@11ty/eleventy-plugin-vite": "^4.0.0",
|
"@11ty/eleventy-plugin-vite": "^4.0.0",
|
||||||
"alpinejs": "^3.12.2",
|
"alpinejs": "^3.12.2",
|
||||||
|
"eleventy-plugin-automatic-noopener": "^2.0.2",
|
||||||
"eleventy-sass": "^2.2.1",
|
"eleventy-sass": "^2.2.1",
|
||||||
"esbuild": "0.17.19"
|
"esbuild": "0.17.19"
|
||||||
},
|
},
|
||||||
|
@ -2587,6 +2588,25 @@
|
||||||
"integrity": "sha512-jdie3RiEgygvDTyS2sgjq71B36q2cDSBfPlwzUyuOrfYTNoYWyBxxjGJV/HAu3A2hB0Y+HesvCVkVAFoCKwCSw==",
|
"integrity": "sha512-jdie3RiEgygvDTyS2sgjq71B36q2cDSBfPlwzUyuOrfYTNoYWyBxxjGJV/HAu3A2hB0Y+HesvCVkVAFoCKwCSw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/eleventy-plugin-automatic-noopener": {
|
||||||
|
"version": "2.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/eleventy-plugin-automatic-noopener/-/eleventy-plugin-automatic-noopener-2.0.2.tgz",
|
||||||
|
"integrity": "sha512-uMHHAG7SUwiuNTd1yPTe8ijIjyTghV9JVXJ/vOUdbu+r3O0aJJ3ARsKAz83GMdSFivrY4XOnenlCOXeovGNBQw==",
|
||||||
|
"dependencies": {
|
||||||
|
"posthtml": "^0.16.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@11ty/eleventy": "*"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@11ty/eleventy": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/eleventy-sass": {
|
"node_modules/eleventy-sass": {
|
||||||
"version": "2.2.1",
|
"version": "2.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/eleventy-sass/-/eleventy-sass-2.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/eleventy-sass/-/eleventy-sass-2.2.1.tgz",
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@11ty/eleventy-plugin-vite": "^4.0.0",
|
"@11ty/eleventy-plugin-vite": "^4.0.0",
|
||||||
"alpinejs": "^3.12.2",
|
"alpinejs": "^3.12.2",
|
||||||
|
"eleventy-plugin-automatic-noopener": "^2.0.2",
|
||||||
"eleventy-sass": "^2.2.1",
|
"eleventy-sass": "^2.2.1",
|
||||||
"esbuild": "0.17.19"
|
"esbuild": "0.17.19"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue