Giter Club home page Giter Club logo

cloak's People

Contributors

azerozvn avatar jonjahr avatar lemoswilson avatar mattaebersold avatar sjstark avatar weotch avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cloak's Issues

Prevent SVGs from being converted to low-resolution srcset

Problem

I came across a situation where, in Contentful, I embedded an SVG image into a rich-text field. On the front end, the image ended up looking low resolution. It was because contentful-visual created srcset and webpSrcset props, and usedContentful CDN image transforms to create a low resolution srcset of WEBP images.

Solution

It would be nice to have a way to tell vue-visual that this is an already-optimized SVG, and please don't generate a srcset for me. Not sure what the best solution here is:

  1. Auto-detect SVG extension and automatically prevent srcset generation?
  2. Add a noSrcset prop?

I lean toward # 1 because in my mind SVGs and srcsets are never compatible.

I can do the work, just want @weotch to weigh in.

Consider auto adding anchor parser internal URLs from Netlify ENVs

Like:

	anchorParser:
		internalUrls: [
			/^https?:\/\/localhost:\d+/

			# Use current URL from Netify
			do ->
				return unless url = process.env.URL
				url = url.replace /[\/\-\.]/g, '\\$&'
				return new RegExp "^#{url}"

			# Use Netlify subdomain URL
			do ->
				return unless name = process.env.SITE_NAME
				name = name.replace /[\-]/g, '\\$&'
				return new RegExp "^https?:\/\/#{name}\.netlify\.app"

Add convention for global meta tags

I didn't directly port this from existing pages because I'd like to find a better way to handle the global defaults. Also, I want to break it up into multiple methods because the current implementation are a sorta cumbersome.

Add auto redirects generation

For example, this is a build module I was using before:

/*
Append redirects that don't end in an anchor to the _redirects file
*/
import axios from "axios"
import { resolve } from "path"
import { readFileSync, writeFileSync } from "fs"

// Query for redirects
const getEntries = `query getRedirects {
	entries(type:"redirects") {
		... on redirects_redirects_Entry {
			from
			to
			code
		}
	}
}`

// Trigger after the static files are copied to the dist, that's the version
// that will get edited
export default async function redirects() {
	this.nuxt.hook("generate:distCopied", async function (builder) {
		console.log("  Adding server side redirects");

		// Open up _redirects
		const file = resolve(__dirname, "../dist", "_redirects")
		let redirects = readFileSync(file, "utf8")

		// Fetch the server side redirects
		const response = await axios({
			url: process.env.CMS_ENDPOINT,
			method: "post",
			headers: {
				"Content-Type": "application/json",
			},
			data: {
				query: getEntries,
			},
		})

		// Add CMS redirects
		response.data.data.entries.forEach((rule) => {
			redirects += `\n${rule.from} ${rule.to} ${rule.code}!`;
		})

		// Write the redirects file
		writeFileSync(file, redirects);
	})
}

Make the placeholder color smarter

  • Disable placeholder color if image is a png (if the CMS provides a mimetype) or has .png as the suffix
  • Change the default color to some translucent black color so it doesn't look bad when over a background color

Implement get-contentful-pages script

  • Transpile contentful page gql files
  • Document that it's expecting gql files that are named the same as the pageName
  • Make the pages script loop through all pageTypes and return routes

Global components don't HMR quickly

Like components/global/btn.vue doesn't update immediately, usually doing a full refresh after a change is quicker. Guessing it's a Nuxt bug but maybe I can workaround it.

Implement a fallback $gtm or come up with other method to disable

When GTM_ID is commented out in .env then we don't load the GTM module at all. However, this means that site's who intended to use GTM but may have it deactivated (like in local dev) will throw an error with calls to @$gtm.push ... meaning you have to remember to use @$gtm?.push.

I think $gtm should always exist.

Add contentful-visual

  • Copy over contentful-visual
  • Move shared code between contentful-visual and craft-visual into cloak-visual, a new functional component that those higher order components use for the majority of their functionality
  • Add gql fragments for Contentful

Consider making generate.fallback: true as a default

This means that a new Craft entry can be previewed before deploy finishes on a SSG site.

Downside is that when the fallback is rendered (like it will on a 404 page), a client side GQL query is made to Craft for data. It would be great to serve this from SSG'ed JSON if possible.

Also, the globals aren't available in the initial payload so you may need to v-if=$store.state.globals.loaded the default layout so that we don't try to use global data on the fallback change (like for header/footer) that doesn't exist yet.

When contentful-visual `natural:true`, the height should scale down when the width scales down.

Example:

Here's a GIF example. This is an image asset embedded in a Contentful Rich Text field. The image's natural size is 1000 x 1000px.

Expected:

The image should be shown at its natural width (1000px). If the container or viewport is too small, then the image should scale down proportionally to fit the container.

Observed:

The width scales down, but the height remains constant (1000px) causing gaps at top and bottom.

Kapture.2021-07-27.at.14.17.06.mp4

I'll commit the solution to this issue branch.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.