angel3_seo

Last updated:

0 purchases

angel3_seo Image
angel3_seo Images
Add to Cart

Description:

angel3 seo

Angel3 SEO #




Helpers for building SEO-friendly Web pages in Angel. The goal of package:angel3_seo is to speed up perceived client page loads, prevent the infamous flash of unstyled content, and other SEO optimizations that can easily become tedious to perform by hand.
Disabling inlining per-element #
Add a data-no-inline attribute to a link or script to prevent inlining it:
<script src="main.dart.js" data-no-inline></script>
copied to clipboard
inlineAssets #
A response finalizer that can be used in any application to patch HTML responses, including those sent with a templating engine like Jael3.
In any text/html response sent down, link and script elements that point to internal resources will have the contents of said file read, and inlined into the HTML page itself.
In this case, "internal resources" refers to a URI without a scheme, i.e. /site.css or foo/bar/baz.js.
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_seo/angel3_seo.dart';
import 'package:angel3_static/angel3_static.dart';
import 'package:file/local.dart';

void main() async {
var app = Angel()..lazyParseBodies = true;
var fs = const LocalFileSystem();
var http = AngelHttp(app);

app.responseFinalizers.add(inlineAssets(fs.directory('web')));

app.use(() => throw AngelHttpException.notFound());

var server = await http.startServer('127.0.0.1', 3000);
print('Listening at http://${server.address.address}:${server.port}');
}
copied to clipboard
inlineAssetsFromVirtualDirectory #
This function is a simple one; it wraps a VirtualDirectory to patch the way it sends .html files. Produces the same functionality as inlineAssets.
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_seo/angel3_seo.dart';
import 'package:angel3_static/angel3_static.dart';
import 'package:file/local.dart';

void main() async {
var app = Angel()..lazyParseBodies = true;
var fs = const LocalFileSystem();
var http = AngelHttp(app);

var vDir = inlineAssets(
VirtualDirectory(
app,
fs,
source: fs.directory('web'),
),
);

app.use(vDir.handleRequest);

app.use(() => throw AngelHttpException.notFound());

var server = await http.startServer('127.0.0.1', 3000);
print('Listening at http://${server.address.address}:${server.port}');
}
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.