All Projects → scottsweb → v1.scott.ee

scottsweb / v1.scott.ee

Licence: other
✅ My website built with nuxt.js and statically generated from WordPress.

Programming Languages

SCSS
7915 projects
Vue
7211 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to v1.scott.ee

Bael Template
Brutalist Blog theme for Netlify CMS
Stars: ✭ 187 (+240%)
Mutual labels:  nuxt, jamstack
Wuxt
Nuxt/WordPress development environment, combining the worlds biggest CMS with the most awesome front-end application framework yet.
Stars: ✭ 459 (+734.55%)
Mutual labels:  nuxt, jamstack
trailing-slash-guide
Understand and fix your static website trailing slash issues!
Stars: ✭ 255 (+363.64%)
Mutual labels:  nuxt, jamstack
Ecommerce Netlify
🛍 A JAMstack Ecommerce Site built with Nuxt and Netlify Functions
Stars: ✭ 1,147 (+1985.45%)
Mutual labels:  nuxt, jamstack
nuxt-starter-netlify-cms
Example nuxt + netlify cms project. Nuxt port of Gatsby starter app.
Stars: ✭ 13 (-76.36%)
Mutual labels:  nuxt, jamstack
nuxt-i18n-boilerplate
A boilerplate for rapid application development using Nuxt i18n.
Stars: ✭ 20 (-63.64%)
Mutual labels:  nuxt
noted
Markdown note-taking with syntax highlighting and real-time preview.
Stars: ✭ 22 (-60%)
Mutual labels:  nuxt
thewhite
✒️ It's a minimal and light wordpress blog theme 🎨
Stars: ✭ 87 (+58.18%)
Mutual labels:  wordpress-theme
hacktoberfest-checker
Decoupled web application using Nuxt and Netlify Functions to create a way for folks to check whether a public repository is eligible and/or taking part in Hacktoberfest
Stars: ✭ 16 (-70.91%)
Mutual labels:  nuxt
jamstack
JAMstack - Paid and Open-Source Boilerplate code | AppSeed
Stars: ✭ 44 (-20%)
Mutual labels:  jamstack
Bulmascores
WordPress starter theme based on Underscores and Bulma
Stars: ✭ 14 (-74.55%)
Mutual labels:  wordpress-theme
awrora-starter
Landing page template built with one of most popular javascript library Vue.JS, Vuetify (Material Design) and Nuxt.JS with SSR.
Stars: ✭ 38 (-30.91%)
Mutual labels:  nuxt
blog-template
A markdown-style blog template for Sapper
Stars: ✭ 29 (-47.27%)
Mutual labels:  jamstack
be.camp
Open source website for the beCamp unconference in Charlottesville, VA
Stars: ✭ 16 (-70.91%)
Mutual labels:  nuxt
webpack-gulp-wordpress-starter-theme
A WordPress theme with Webpack & Gulp
Stars: ✭ 110 (+100%)
Mutual labels:  wordpress-theme
jamstack-preview-and-deployments
Preview and deploy NextJS applications from the wordpress admin.
Stars: ✭ 17 (-69.09%)
Mutual labels:  jamstack
caglarturali.github.io
Personal portfolio website repository.
Stars: ✭ 260 (+372.73%)
Mutual labels:  jamstack
blog3.0
博客V3.0 目前使用的技术(Nuxtjs + Nestjs + Vue + Element ui + vuetify),存储(MongoDB + Redis + COS)
Stars: ✭ 37 (-32.73%)
Mutual labels:  nuxt
wordpress
Free PWA & SPA for Wordpress & Woocommerce
Stars: ✭ 103 (+87.27%)
Mutual labels:  nuxt
admin-one-nuxt
Admin One Nuxt - Nuxt.js Bulma Buefy admin dashboard
Stars: ✭ 23 (-58.18%)
Mutual labels:  nuxt

scott.ee

scott.ee

About

This is the repo for my personal website created with nuxt.js. The site is statically generated from a remotely hosted WordPress API. A full write up of how it is put together can be found on my journal.

The site is hosted on GitHub pages and on the peer to peer web, using dat (dat://scott.ee).

Development / Building

# install dependencies
$ npm install # Or yarn install

# serve with hot reload at localhost:3000
$ npm run dev

# generate static project
$ npm run generate

# generate content only (use when new content is posted to WP)
$ npm run generate-content

# push the dist branch to GitHub pages
$ npm run deploy-gh

WordPress Images

To enable lazyload compatability add the following code to your WordPress site:

function add_lazyload( $content ) {
	// exit early if not API request
	if ( ! defined( 'REST_REQUEST' ) ) {
		return $content;
	}

	$content = mb_convert_encoding( $content, 'HTML-ENTITIES', 'UTF-8' );
	$dom = new DOMDocument();
	@$dom->loadHTML( $content );

	$div = $dom->createElement( 'div' );
	$div->setAttribute( 'class', 'lazy' );

	// Convert Images
	$images = [];

	foreach ( $dom->getElementsByTagName( 'img' ) as $node ) {
		$images[] = $node;
	}

	foreach ( $images as $node ) {
		$fallback = $node->cloneNode( true );
		$wrapper = $div->cloneNode();

		$oldsrc = $node->getAttribute( 'src' );
		$node->setAttribute( 'data-src', $oldsrc );
		$node->setAttribute( 'src', '' );

		// extract dimensions from src and calculate an aspect ratio
		$regex = '/resize=([0-9]*)%2C([0-9]*)/m';
		preg_match( $regex, $oldsrc, $matches );
		if ( is_array( $matches ) && ! empty( $matches ) ) {
			$wrapper->setAttribute( 'data-width', $matches[1] );
			$wrapper->setAttribute( 'data-height', $matches[2] );
			$wrapper->setAttribute( 'style', '--ratio:' . round( ( $matches[2] / $matches[1] ) * 100, 2 ) . '%;' );
		} else {
			$wrapper->setAttribute( 'style', '--ratio: 50%;' );
		}

		$oldsrcset = $node->getAttribute( 'srcset' );
		$node->setAttribute( 'data-srcset', $oldsrcset );
		$node->setAttribute( 'srcset', '' );

		$noscript = $dom->createElement( 'noscript', '' );
		$node->parentNode->insertBefore( $noscript, $node );
		$noscript->appendChild( $fallback );

		$node->parentNode->replaceChild( $wrapper, $node );
		$wrapper->appendChild( $node );
	}

	$newhtml = preg_replace( '/^<!DOCTYPE.+?>/', '', str_replace( array( '<html>', '</html>', '<body>', '</body>' ), array( '', '', '', '' ), $dom->saveHTML() ) );
	return $newhtml;
}
add_filter( 'the_content', 'add_lazyload', 100 );
add_filter( 'post_thumbnail_html', 'add_lazyload', 100 );

WordPress Redirect Functionality

To redirect your WordPress site / API to production you can use this snippet. It might be an idea not to redirect logged in users in order to preserve the post preview functionality in WordPress.

function add_redirects() {
	global $wp;
	if ( ! is_admin() && ! is_feed() ) {
		wp_redirect( str_replace( 'api.', '', home_url( $wp->request ) ), 301 );
		exit;
	}
}
add_filter( 'template_redirect', 'add_redirects' );

WordPress Feed URLs

I am also experimenting with changing the URLs within the RSS feed to reduce redirects. The RSS feed is still currently being served from the WordPress side at api.scott.ee/feed/.

function fix_feed_home_url( $home ) {
	if ( is_feed() ) {
		return str_replace( 'api.', '', $home );
	}
	return $home;
}
add_filter( 'home_url', 'fix_feed_home_url' );

Further Reading

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].