diff --git a/website/src/app/f/[...path]/page.tsx b/website/src/app/f/[...path]/page.tsx index ffc4af2..aa93352 100644 --- a/website/src/app/f/[...path]/page.tsx +++ b/website/src/app/f/[...path]/page.tsx @@ -3,7 +3,7 @@ import { ShareButton } from "@/components/ShareButton"; import { BackButton } from "@/components/BackButton"; import { Doc, data, manualLinks } from "@/models/data"; import { getPrimopDescription } from "@/models/primop"; -import { extractHeadings, mdxRenderOptions } from "@/utils"; +import { extractExcerpt, extractHeadings, mdxRenderOptions } from "@/utils"; import { Box, Divider, Typography, Link, Chip } from "@mui/material"; import { MDXRemote } from "next-mdx-remote/rsc"; import { findType, interpretType } from "@/models/nix"; @@ -50,10 +50,12 @@ const Toc = async (props: TocProps) => { whiteSpace: "nowrap", }} > - On this page + + On this page + {title && ( - + { )} {headings.map((h, idx) => ( - + { + // console.log({ word }); + // }); + // console.log({ excerpt }); + + const name = item?.meta.path[item?.meta.path.length - 1]; + + const content = item?.content?.content || ""; + + const summary = await extractExcerpt(content, 35); + const description = await extractExcerpt(content, 200); + + const title = `Nix ${name} - ${summary}`; + return { + // should be 20-70 characters title, - description: item?.content?.content, + // should be 70-160 characters + description, authors: [ { name: "nixos", url: "https://nixos.org/" }, { name: "nixpkgs", url: "https://github.com/NixOS/nixpkgs" }, @@ -233,7 +250,7 @@ export default async function Page(props: { params: { path: string[] } }) { idx === all.length - 1 ? ( - + {attr} @@ -348,7 +365,7 @@ export default async function Page(props: { params: { path: string[] } }) {
- Learn about functors + + Learn about functors + )} {!!meta?.aliases?.length && ( <> Aliases @@ -381,7 +400,9 @@ export default async function Page(props: { params: { path: string[] } }) {
    {meta?.aliases?.map((a) => (
  • - {a.join(".")} + + {a.join(".")} +
  • ))}
diff --git a/website/src/app/layout.tsx b/website/src/app/layout.tsx index aea4944..aa322c4 100644 --- a/website/src/app/layout.tsx +++ b/website/src/app/layout.tsx @@ -6,7 +6,7 @@ import { ClientSideLayoutContext } from "@/components/ClientSideLayoutContext"; import { Metadata } from "next"; export const metadata: Metadata = { - title: "Noogle", + title: "Noogle - Simply find Nix API reference documentation.", description: "Nix API reference. Includes nix, nixpkgs and nixos. Search nix functions within the nix ecosystem based on type, name, description, example, category and more.", creator: "@hsjobeki", diff --git a/website/src/app/page.tsx b/website/src/app/page.tsx index b075240..8d7fdd5 100644 --- a/website/src/app/page.tsx +++ b/website/src/app/page.tsx @@ -24,7 +24,7 @@ export default function Home() { alignItems: "center", }} > - + { const matter = await getMdxMeta(entry); const { frontmatter } = matter.compiled; return ( - + {meta.title}} + primary={ + + {meta.title} + + } secondary={
} diff --git a/website/src/components/PositionLink.tsx b/website/src/components/PositionLink.tsx index fb7d7a9..f785c99 100644 --- a/website/src/components/PositionLink.tsx +++ b/website/src/components/PositionLink.tsx @@ -49,6 +49,7 @@ export const PositionLink = ({ <> This function is not declared in a .nix file @@ -56,6 +57,7 @@ export const PositionLink = ({ {!is_primop && ( This is very likely a bug in noogle please report this error. @@ -143,7 +145,11 @@ export const PositionLink = ({ )} - + {contentPosition && is_inherited && `(${content_meta?.path?.join(".")})`} @@ -151,7 +157,7 @@ export const PositionLink = ({ {!content?.content && ( <> - + {"Contribute"} - {/* */} )} diff --git a/website/src/components/SearchNav.tsx b/website/src/components/SearchNav.tsx index 92a161b..21cc082 100644 --- a/website/src/components/SearchNav.tsx +++ b/website/src/components/SearchNav.tsx @@ -90,6 +90,7 @@ export const Navigation = ({ {prev && ( + {meta.title} } diff --git a/website/src/components/filter.tsx b/website/src/components/filter.tsx index a6bdc78..bb0f66a 100644 --- a/website/src/components/filter.tsx +++ b/website/src/components/filter.tsx @@ -133,7 +133,11 @@ export const Filter = (props: FilterProps) => { }} > - + From @@ -184,7 +188,11 @@ export const Filter = (props: FilterProps) => { }} > - + To diff --git a/website/src/components/layout/header.tsx b/website/src/components/layout/header.tsx index 1db6d6c..660751d 100644 --- a/website/src/components/layout/header.tsx +++ b/website/src/components/layout/header.tsx @@ -46,6 +46,7 @@ export const Header = () => { }} > { width: "100%", }} > - + => { + const processor = unified() + .use(remarkParse) + .use(remarkRehype) + .use(rehypeExtractExcerpt, { + maxLength: maxLength, + ellipsis: " ...", + }) + .use(rehypeStringify); + + const result = await processor.process(content); + + return result.data.excerpt as string; +}; export const extractHeadings = async (content: string): Promise => { const processor = unified() .use(remarkParse)