1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-26 15:28:28 -04:00

stop generating algolia.json (temporarily) & other tidying up

This commit is contained in:
Jake Jarvis 2020-07-20 09:01:12 -04:00
parent 2909e934e7
commit bc03922573
Signed by: jake
GPG Key ID: 2B0C9CF251E69A39
11 changed files with 14 additions and 180 deletions

View File

@ -1 +0,0 @@
plugins/

2
.gitattributes vendored
View File

@ -1,2 +0,0 @@
# Set default behavior to automatically normalize line endings.
* text=auto eol=lf

View File

@ -9,9 +9,6 @@ builds/
resources/ resources/
_vendor/ _vendor/
# Netlify plugins
plugins/
# dotfiles/config # dotfiles/config
.* .*
postcss.config.js postcss.config.js

View File

@ -28,17 +28,17 @@ disableAliases = true
description = "Hi there! I'm a frontend web developer based in Boston, Massachusetts specializing in the JAMstack, modern JavaScript frameworks, and progressive web apps." description = "Hi there! I'm a frontend web developer based in Boston, Massachusetts specializing in the JAMstack, modern JavaScript frameworks, and progressive web apps."
image = "img/logo.png" # relative to assetDir root image = "img/logo.png" # relative to assetDir root
mainSection = "notes" # content that appears in feeds mainSection = "notes" # content that appears in feeds
[params.social] [params.theme]
githubRepo = "jakejarvis/jarv.is" # user/repo maxWidth = 940 # px
webmentionIO = "jarv.is" # webmention.io username defaultTheme = "light" # light or dark?
facebookAppID = 3357248167622283
[params.license] [params.license]
name = "CC-BY-4.0" name = "CC-BY-4.0"
nameLong = "Creative Commons Attribution 4.0 International" nameLong = "Creative Commons Attribution 4.0 International"
copyrightFirstYear = 2001 copyrightFirstYear = 2001
[params.theme] [params.social]
maxWidth = 940 # px githubRepo = "jakejarvis/jarv.is" # user/repo
defaultTheme = "light" # light or dark? webmentionIO = "jarv.is" # webmention.io username
facebookAppID = 3357248167622283
[author] [author]
name = "Jake Jarvis" name = "Jake Jarvis"
@ -90,7 +90,7 @@ disableAliases = true
weight = -70 weight = -70
[outputs] [outputs]
home = ["HTML", "RSS", "ATOM", "ALGOLIA", "MANIFEST", "REDIRECTS", "HEADERS"] home = ["HTML", "RSS", "ATOM", "MANIFEST", "REDIRECTS", "HEADERS"]
section = ["HTML"] section = ["HTML"]
page = ["HTML", "AMP"] page = ["HTML", "AMP"]
@ -138,7 +138,7 @@ disableAliases = true
[mediaTypes."application/manifest+json"] [mediaTypes."application/manifest+json"]
suffixes = ["webmanifest"] suffixes = ["webmanifest"]
[mediaTypes."text/netlify"] [mediaTypes."text/netlify"]
delimiter = "" # no extension for _headers & _redirects files delimiter = "" # no dot/extension for _headers & _redirects files
[sitemap] [sitemap]
filename = "sitemap.xml" filename = "sitemap.xml"

View File

@ -41,13 +41,11 @@
# Cache resoures between builds: # Cache resoures between builds:
# https://github.com/jakejarvis/netlify-plugin-cache # https://github.com/jakejarvis/netlify-plugin-cache
[[plugins]] [[plugins]]
package = "@netlify/plugin-local-install-core" package = "netlify-plugin-cache"
[[plugins]]
package = "./plugins/netlify-plugin-cache"
[plugins.inputs] [plugins.inputs]
paths = ["resources", "public", "_vendor"] paths = ["resources", "public", "_vendor"]
[[plugins]] # [[plugins]]
package = "netlify-plugin-debug-cache" # package = "netlify-plugin-debug-cache"
# The most important headers and redirects are specified in the _headers and # The most important headers and redirects are specified in the _headers and
# _redirects files generated by Hugo. These are additional custom rules. # _redirects files generated by Hugo. These are additional custom rules.

View File

@ -14,7 +14,7 @@
"url": "git+https://github.com/jakejarvis/jarv.is.git" "url": "git+https://github.com/jakejarvis/jarv.is.git"
}, },
"scripts": { "scripts": {
"clean": "hugo mod clean && rimraf public/ resources/ builds/ _vendor/ .netlify/functions/ $TMPDIR/hugo_cache/ || true", "clean": "hugo mod clean && rimraf public/ resources/ builds/ _vendor/ .netlify/{cache,functions}/ $TMPDIR/hugo_cache/ || true",
"build": "run-s build:hugo build:functions minify", "build": "run-s build:hugo build:functions minify",
"build:hugo": "hugo --gc --cleanDestinationDir --verbose", "build:hugo": "hugo --gc --cleanDestinationDir --verbose",
"build:functions": "netlify-lambda build functions", "build:functions": "netlify-lambda build functions",
@ -30,9 +30,7 @@
"lint:scss": "stylelint 'assets/sass/**/*.scss' --syntax scss", "lint:scss": "stylelint 'assets/sass/**/*.scss' --syntax scss",
"lint:js": "eslint 'assets/js/**/*.js' 'functions/**/*.js'", "lint:js": "eslint 'assets/js/**/*.js' 'functions/**/*.js'",
"lint:md": "markdownlint 'content/**/*.md'", "lint:md": "markdownlint 'content/**/*.md'",
"lint:prettier": "prettier --check .", "lint:prettier": "prettier --check ."
"index": "run-s clean build:hugo index:**",
"index:algolia": "npx atomic-algolia"
}, },
"dependencies": { "dependencies": {
"normalize.css": "8.0.1", "normalize.css": "8.0.1",

View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2020 Jake Jarvis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,48 +0,0 @@
# ⚡ Netlify Plugin: Custom Cache [![npm](https://img.shields.io/npm/v/netlify-plugin-cache?logo=npm&color=red)](https://www.npmjs.com/package/netlify-plugin-cache) ![CI](https://github.com/jakejarvis/netlify-plugin-cache/workflows/CI/badge.svg)
A generic cache plugin for saving and restoring files and/or folders between Netlify builds for impressive speed improvements. Worry less about running out of build minutes! ⏰
Essentially, this plugin is a pretty wrapper around [Netlify's native cache utility](https://github.com/netlify/build/blob/master/packages/cache-utils/README.md) — it isn't tied to any specific static site generator (on purpose).
## 💿 Install
Add the following lines to your `netlify.toml`:
```toml
[[plugins]]
package = "netlify-plugin-cache"
[plugins.inputs]
# Optional (but highly recommended). Defaults to [".cache"].
paths = ["resources", "_vendor", "folder/file.md"]
```
This plugin only takes one input named `paths`: an array of files and/or directories relative to your project's root. These files/directories are restored before a build and saved in cache after a build **if it is successful**.
**🚨 Important:** `paths` defaults to `[".cache"]`, but it's **highly recommended** you set this yourself based on the tool(s) you're using to generate your site. See examples below.
Read more about plugin configuration at [the official Netlify Plugin docs](https://docs.netlify.com/configure-builds/build-plugins/#install-a-plugin).
## 👩‍💻 Usage
- **Hugo:** Caching the `resources` directory can speed up your build greatly if you [process](https://gohugo.io/content-management/image-processing/) a lot of images, or compile SASS/SCSS via Hugo pipes. You can also cache the `public` directory to avoid completely rebuilding the entire site on each deploy. [More info here.](https://gohugo.io/getting-started/directory-structure/#directory-structure-explained)
- **Gatsby:** By default, the `.cache` directory holds persistent data between builds. You can also cache the `dist` directory to avoid completely rebuilding the entire site on each deploy. [More info here.](https://www.gatsbyjs.org/docs/build-caching/)
- **Jekyll:** A caching API was added as of v4. The notoriously slow SSG can become (relatively) faster by caching the `.jekyll-cache` directory. [More info here.](https://jekyllrb.com/tutorials/cache-api/)
- **Next.js:** The `.next` directory holds the build output. [More info here.](https://nextjs.org/docs/api-reference/next.config.js/setting-a-custom-build-directory)
- **Anything else:** This is the reason I kept this plugin as generic as possible! Research the caching behavior of your static site generator (and how to customize it if necessary). Feel free to open a PR and list it here as well!
## 🐛 Debugging
This plugin doesn't provide a way to output a list of files that were cached or restored, because Netlify already provides an official plugin named [`netlify-plugin-debug-cache`](https://github.com/netlify-labs/netlify-plugin-debug-cache) to do exactly that. No need to re-invent the wheel!
You can add the debug plugin **after** this plugin in your `netlify.toml`. (And yes, you need a `[[plugins]]` line for _each_ plugin you add.)
```toml
[[plugins]]
package = "netlify-plugin-debug-cache"
```
The debug plugin will generate a file named `cache-output.json` at the root of your project's publish directory. [See an example file](https://infallible-wing-581e78.netlify.app/cache-output.json) or [learn more about this plugin](https://github.com/netlify-labs/netlify-plugin-debug-cache).
## 📜 License
This project is distributed under the [MIT license](LICENSE).

View File

@ -1,37 +0,0 @@
// Netlify Plugin: netlify-plugin-cache
// https://github.com/jakejarvis/netlify-plugin-cache
//
// This plugin is essentially a wrapper around Netlify's native `cache-utils`:
// https://github.com/netlify/build/blob/master/packages/cache-utils/README.md
module.exports = {
// Try to restore cache before build begins, if it exists
onPreBuild: async ({ utils: { cache }, inputs }) => {
if (await cache.restore(inputs.paths)) {
const files = await cache.list(inputs.paths)
console.log(`Successfully restored: ${inputs.paths.join(', ')} ... ${files.length} files in total.`)
} else {
console.log(`A cache of '${inputs.paths.join(', ')}' doesn't exist (yet).`)
}
},
// Only save/update cache if build was successful
onSuccess: async ({ utils: { cache, status }, inputs }) => {
if (await cache.save(inputs.paths)) {
const files = await cache.list(inputs.paths)
console.log(`Successfully cached: ${inputs.paths.join(', ')} ... ${files.length} files in total.`)
// Show success & more detail in deploy summary
status.show({
title: `${files.length} files cached`,
summary: 'These will be restored on the next build! ⚡',
text: `${inputs.paths.join(', ')}`
})
} else {
// This probably happened because the default `paths` is set, so provide instructions to fix
console.log(`Attempted to cache: ${inputs.paths.join(', ')} ... but failed. :(`)
console.log('Try setting the \'paths\' input appropriately in your netlify.toml configuration.')
console.log('More details: https://jrvs.io/netlify-cache-usage')
}
}
}

View File

@ -1,5 +0,0 @@
name: netlify-plugin-cache
inputs:
- name: paths
description: Array of files and/or directories to cache between builds.
default: [".cache"]

View File

@ -1,45 +0,0 @@
{
"name": "netlify-plugin-cache",
"version": "1.0.3",
"description": "Generic cache plugin for saving and restoring files and/or folders between Netlify builds",
"license": "MIT",
"author": {
"name": "Jake Jarvis",
"email": "jake@jarv.is",
"url": "http://jarv.is/"
},
"homepage": "https://github.com/jakejarvis/netlify-plugin-cache#readme",
"bugs": "https://github.com/jakejarvis/netlify-plugin-cache/issues",
"repository": {
"type": "git",
"url": "git+https://github.com/jakejarvis/netlify-plugin-cache.git"
},
"main": "index.js",
"scripts": {
"build": "netlify build",
"test": "xo"
},
"dependencies": {},
"devDependencies": {
"netlify-cli": "*",
"xo": "~0.32.0"
},
"engines": {
"node": ">=10.18"
},
"keywords": [
"netlify",
"netlify-plugin",
"cache",
"ci",
"build",
"plugin"
],
"xo": {
"semicolon": false,
"space": 2,
"rules": {
"object-curly-spacing": 0
}
}
}