Skip to content

Commit

Permalink
Improve title
Browse files Browse the repository at this point in the history
  • Loading branch information
naoki-tomita committed Apr 20, 2023
1 parent c973289 commit 4ba173d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/components/Title.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { h, Component } from "zheleznaya";
let title: HTMLTitleElement = globalThis?.document?.querySelector("title")!;

export const Title: Component<{ label: string }> = ({ label }) => {
if (title) {
title.innerText = label;
}
return <div></div>
}
2 changes: 2 additions & 0 deletions app/pages/documents/_id_.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Content } from "../../components/Content";
import { Html } from "../../components/Html";
import { readFileAsync } from "../../FSUtils";
import { styled } from "zstyl";
import { Title } from "../../components/Title";

function markedAsync(md: string) {
return new Promise<string>((ok, ng) => marked(md, (e, d) => e ? ng(e) : ok(d)));
Expand Down Expand Up @@ -87,6 +88,7 @@ const Document: Component<{
return (
<div>
<Header />
<Title label={`${current.title} | nzxt document`} />
<Content>
<CenteredFlex>
<TableOfContents>
Expand Down
2 changes: 2 additions & 0 deletions app/pages/documents/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Content } from "../../components/Content";
import { Header } from "../../components/Header";
import { join } from "path"
import { readFileAsync } from "../../FSUtils";
import { Title } from "../../components/Title";

interface Props {
toc: Content[];
Expand Down Expand Up @@ -33,6 +34,7 @@ const Documents: Component<Props> = ({ toc }) => {
return (
<div>
<Header />
<Title label="contents | nzxt document" />
<Content>
<h1>Contents</h1>
<ContentList toc={toc} />
Expand Down
2 changes: 2 additions & 0 deletions app/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { h, Component } from "nzxt/h";
import { styled } from "zstyl";
import { Content } from "../components/Content";
import { Header } from "../components/Header";
import { Title } from "../components/Title";

const CenteredFlex = styled.div`
display: flex;
Expand All @@ -21,6 +22,7 @@ const Index: Component = () => {
return (
<div>
<Header />
<Title label="nzxt document" />
<Content>
<CenteredFlex>
<div>
Expand Down

0 comments on commit 4ba173d

Please sign in to comment.