Updated seo

This commit is contained in:
thomashii 2021-08-20 10:33:49 +08:00
parent d440590c2c
commit ee3c087ef5
8 changed files with 66 additions and 72 deletions

View file

@ -1,8 +1,18 @@
# 3.0.0
# Change Log
## 4.0.0
* Updated to use `angel3` packages
* Published with `angel3` prefix
## 3.0.0
* Migrated to support Dart SDK 2.12.x NNBD
# 2.0.0
## 2.0.0
* Angel 2 updates.
# 1.0.0
## 1.0.0
* Initial release.

View file

@ -1,6 +1,6 @@
MIT License
MIT License (MIT)
Copyright (c) 2018 The Angel Framework
Copyright (c) 2021 dukefirehawk.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -1,14 +1,16 @@
# seo
[![Pub](https://img.shields.io/pub/v/angel_seo.svg)](https://pub.dartlang.org/packages/angel_seo)
[![build status](https://travis-ci.org/angel-dart/seo.svg?branch=master)](https://travis-ci.org/angel-dart/seo)
# Angel3 SEO
Helpers for building SEO-friendly Web pages in Angel. The goal of
`package:angel_seo` is to speed up perceived client page loads, prevent
the infamous
[flash of unstyled content](https://en.wikipedia.org/wiki/Flash_of_unstyled_content),
and other SEO optimizations that can easily become tedious to perform by hand.
[![version](https://img.shields.io/badge/pub-v4.0.0-brightgreen)](https://pub.dartlang.org/packages/angel3_seo)
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion)
[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/packages/seo/LICENSE)
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](https://en.wikipedia.org/wiki/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:
```html
@ -16,31 +18,27 @@ Add a `data-no-inline` attribute to a `link` or `script` to prevent inlining it:
```
## `inlineAssets`
A
[response finalizer](https://angel-dart.gitbook.io/angel/the-basics/request-lifecycle)
that can be used in any application to patch HTML responses, including those sent with
a templating engine like Jael.
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.
A [response finalizer](https://angel3-docs.dukefirehawk.com/guides/request-lifecycle) that can be used in any application to patch HTML responses, including those sent with a templating engine like Jael3.
In this case, "internal resources" refers to a URI *without* a scheme, i.e. `/site.css` or
`foo/bar/baz.js`.
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`.
```dart
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_seo/angel_seo.dart';
import 'package:angel_static/angel_static.dart';
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';
main() async {
var app = new Angel()..lazyParseBodies = true;
void main() async {
var app = Angel()..lazyParseBodies = true;
var fs = const LocalFileSystem();
var http = new AngelHttp(app);
var http = AngelHttp(app);
app.responseFinalizers.add(inlineAssets(fs.directory('web')));
app.use(() => throw new AngelHttpException.notFound());
app.use(() => throw AngelHttpException.notFound());
var server = await http.startServer('127.0.0.1', 3000);
print('Listening at http://${server.address.address}:${server.port}');
@ -48,24 +46,22 @@ main() async {
```
## `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`.
This function is a simple one; it wraps a `VirtualDirectory` to patch the way it sends `.html` files. Produces the same functionality as `inlineAssets`.
```dart
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_seo/angel_seo.dart';
import 'package:angel_static/angel_static.dart';
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';
main() async {
var app = new Angel()..lazyParseBodies = true;
void main() async {
var app = Angel()..lazyParseBodies = true;
var fs = const LocalFileSystem();
var http = new AngelHttp(app);
var http = AngelHttp(app);
var vDir = inlineAssets(
new VirtualDirectory(
VirtualDirectory(
app,
fs,
source: fs.directory('web'),
@ -74,7 +70,7 @@ main() async {
app.use(vDir.handleRequest);
app.use(() => throw new AngelHttpException.notFound());
app.use(() => throw AngelHttpException.notFound());
var server = await http.startServer('127.0.0.1', 3000);
print('Listening at http://${server.address.address}:${server.port}');

View file

@ -1,8 +1,8 @@
import 'dart:convert';
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_framework/http.dart';
import 'package:angel_seo/angel_seo.dart';
import 'package:angel_static/angel_static.dart';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart';
import 'package:angel3_seo/angel3_seo.dart';
import 'package:angel3_static/angel3_static.dart';
import 'package:file/local.dart';
import 'package:http_parser/http_parser.dart';

View file

@ -1,7 +1,7 @@
import 'dart:async';
import 'dart:convert';
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_static/angel_static.dart';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_static/angel3_static.dart';
import 'package:file/file.dart';
import 'package:html/dom.dart' as html;
import 'package:html/parser.dart' as html;

View file

@ -1,31 +1,19 @@
name: angel_seo
version: 2.0.0
description: Helper infrastructure for building SEO-friendly Web backends in Angel.
homepage: https://github.com/angel-dart/seo
publish_to: none
name: angel3_seo
version: 4.0.0
description: Helper infrastructure for building SEO-friendly Web backends in Angel3.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/seo
environment:
sdk: '>=2.12.0 <3.0.0'
dependencies:
angel_framework:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x_nnbd
path: packages/framework
angel_static:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x_nnbd
path: packages/static
angel3_framework: ^4.1.0
angel3_static: ^4.0.0
file: ^6.1.2
html: ^0.15.0
http_parser: ^4.0.0
path: ^1.8.0
dev_dependencies:
angel_test:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x_nnbd
path: packages/test
angel3_test: ^4.0.0
logging: ^1.0.1
test: ^1.17.8
pedantic: ^1.11.1

View file

@ -1,7 +1,7 @@
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_seo/angel_seo.dart';
import 'package:angel_static/angel_static.dart';
import 'package:angel_test/angel_test.dart';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_seo/angel3_seo.dart';
import 'package:angel3_static/angel3_static.dart';
import 'package:angel3_test/angel3_test.dart';
import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:html/dom.dart' as html;