Skip to content

Commit

Permalink
setHead
Browse files Browse the repository at this point in the history
  • Loading branch information
herudi committed May 23, 2022
1 parent 61d23e2 commit 695da90
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Van Router

[![ci](https://github.com/herudi/van-router/workflows/ci/badge.svg)](https://github.com/herudi/van-router)
[![npm version](https://img.shields.io/badge/npm-0.6.3-blue.svg)](https://npmjs.org/package/van-router)
[![npm version](https://img.shields.io/badge/npm-0.6.4-blue.svg)](https://npmjs.org/package/van-router)
[![License](https://img.shields.io/:license-mit-blue.svg)](http://badges.mit-license.org)
[![download-url](https://img.shields.io/npm/dm/van-router.svg)](https://npmjs.org/package/van-router)
[![minzip](https://img.shields.io/bundlephobia/minzip/van-router)](https://github.com/herudi/van-router)
Expand Down Expand Up @@ -47,7 +47,7 @@ const { createRouter } = require("van-router");
### Deno

```ts
import { createRouter } from "https://deno.land/x/van_router@0.6.3/mod.ts";
import { createRouter } from "https://deno.land/x/van_router@0.6.4/mod.ts";
```

## Usage
Expand Down Expand Up @@ -203,7 +203,7 @@ Config for VanRouter
```js
// types
type Config = {
render?: (elem: any) => void;
render?: (elem: any) => any;
base?: string;
hash?: boolean;
}
Expand Down Expand Up @@ -530,7 +530,7 @@ http.createServer(async (request, response) => {
## With Deno (Server-Rendered)

```ts
import { createRouter } from "https://deno.land/x/van_router@0.6.3/mod.ts";
import { createRouter } from "https://deno.land/x/van_router@0.6.4/mod.ts";
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";

const port = 8080;
Expand Down
14 changes: 8 additions & 6 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,14 @@ class Router<Ctx extends Context = Context> {
return (a == "title>" ? "" : " van-head") + a;
});
if (!isServer) {
const title = w.document.querySelector("title");
if (title) title.remove();
const arr = w.document.querySelectorAll("[van-head]");
for (let i = 0; i < arr.length; i++) arr[i].remove();
const h = w.document.querySelector("head");
if (h) h.insertAdjacentHTML("beforeend", tag);
if (str.indexOf("</title>") !== -1) {
const title = w.document.querySelector("title");
if (title) title.remove();
}
w.document.querySelectorAll("[van-head]").forEach((el: TRet) =>
el.remove()
);
w.document.head.insertAdjacentHTML("beforeend", tag);
}
s._head = tag;
};
Expand Down
2 changes: 1 addition & 1 deletion scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as esbuild from "https://deno.land/x/esbuild@v0.14.25/mod.js";

const VERSION = "0.6.3";
const VERSION = "0.6.4";

const dir = Deno.cwd();
const dir_npm = dir + "/npm";
Expand Down

0 comments on commit 695da90

Please sign in to comment.