<commit_before>import React from "react";
import { Link } from "@curi/react-dom";

import BasePackage from "./base/BasePackage";
import APIBlock from "./base/APIBlock";
import {
  InlineJS as IJS,
  InlineComponent as Cmp
} from "../../components/PrismBlocks";
import { Section, Subsection } from "../../components/Sections";
import {
  SideBySide,
  CodeBlock,
  Explanation
} from "../../components/SideBySide";
import { Note } from "../../components/Messages";

export default class StaticPackage extends React.PureComponent {
  render() {
    const { name, version, globalName } = this.props;
    return (
      <BasePackage
        name={name}
        version={version}
        globalName={globalName}
        unpkg={false}
        about={
          <div>
            <p>
              The <IJS>@curi/static</IJS> package is for creating static assets
              for your server. Its exported functions should be used in a build
              script, not the source of an application.
            </p>
          </div>
        }
      >
        <APIBlock>
          <Section tag="h3" title="staticFiles()" id="staticFiles">
            <SideBySide>
              <Explanation>
                <p>
                  The <IJS>staticFiles()</IJS> function is used to generate HTML
                  files for a static website and save them to the disk. An HTML
                  file will be created for each page that you provide.
                </p>
                <p>
                  Files will be created as <IJS>index.html</IJS> in the
                  directory for their path. For example, the page for the
                  pathname <IJS>/about</IJS> would create an{" "}
                  <IJS>/about/index.html</IJS> file.
                </p>
              </Explanation>
              <CodeBlock>
                {`import { staticFiles } from '@curi/static';
import { join } from "path";

import routes from "../src/routes";

staticFiles({
  routes,
  pages: [{ name}],
  outputDir: join(process.cwd(), "public"),
  render: () => {...},
  insert: () => {...}
});`}
              </CodeBlock>
            </SideBySide>

            <SideBySide>
              <Explanation>
                <p>
                  <IJS>staticFiles()</IJS> returns a Promise that resolve with
                  an array of results. Each entry in the results array contains
                  the <IJS>pathname</IJS> of the result, a <IJS>success</IJS>{" "}
                  boolean, and, if <IJS>success</IJS> is false, the{" "}
                  <IJS>error</IJS> that occurred.
                </p>
                <p>
                  It can be useful to log the results to easily see what pages
                  were successfully built and which had issues.
                </p>
              </Explanation>
              <CodeBlock>
                {`staticFiles({...})
  .then(results => {
    const resultString = results
      .map(result => {
        return result.success
          ? \`✔ \${result.pathname}\`<commit_msg>(docs) Fix incomplete staticFiles() example [ci skip]<commit_after>import React from "react";
import { Link } from "@curi/react-dom";

import BasePackage from "./base/BasePackage";
import APIBlock from "./base/APIBlock";
import {
  InlineJS as IJS,
  InlineComponent as Cmp
} from "../../components/PrismBlocks";
import { Section, Subsection } from "../../components/Sections";
import {
  SideBySide,
  CodeBlock,
  Explanation
} from "../../components/SideBySide";
import { Note } from "../../components/Messages";

export default class StaticPackage extends React.PureComponent {
  render() {
    const { name, version, globalName } = this.props;
    return (
      <BasePackage
        name={name}
        version={version}
        globalName={globalName}
        unpkg={false}
        about={
          <div>
            <p>
              The <IJS>@curi/static</IJS> package is for creating static assets
              for your server. Its exported functions should be used in a build
              script, not the source of an application.
            </p>
          </div>
        }
      >
        <APIBlock>
          <Section tag="h3" title="staticFiles()" id="staticFiles">
            <SideBySide>
              <Explanation>
                <p>
                  The <IJS>staticFiles()</IJS> function is used to generate HTML
                  files for a static website and save them to the disk. An HTML
                  file will be created for each page that you provide.
                </p>
                <p>
                  Files will be created as <IJS>index.html</IJS> in the
                  directory for their path. For example, the page for the
                  pathname <IJS>/about</IJS> would create an{" "}
                  <IJS>/about/index.html</IJS> file.
                </p>
              </Explanation>
              <CodeBlock>
                {`import { staticFiles } from '@curi/static';
import { join } from "path";

import routes from "../src/routes";

staticFiles({
  routes,
  pages: [{ name: "Home" }, { name: "About" }],
  outputDir: join(process.cwd(), "public"),
  render: () => {...},
  insert: () => {...}
});`}
              </CodeBlock>
            </SideBySide>

            <SideBySide>
              <Explanation>
                <p>
                  <IJS>staticFiles()</IJS> returns a Promise that resolve with
                  an array of results. Each entry in the results array contains
                  the <IJS>pathname</IJS> of the result, a <IJS>success</IJS>{" "}
                  boolean, and, if <IJS>success</IJS> is false, the{" "}
                  <IJS>error</IJS> that occurred.
                </p>
                <p>
                  It can be useful to log the results to easily see what pages
                  were successfully built and which had issues.
                </p>
              </Explanation>
              <CodeBlock>
                {`staticFiles({...})
  .then(results => {
    const resultString = results
      .map(result => {
        return result.success
          ? \`✔ \${result.pathname}\`
{'fraction_non_alphanumeric': 0.12084148727984344, 'fraction_numerical': 0.00032615786040443573, 'mean_word_length': 1.6220607097050022, 'pattern_counts': {'":': 0, '<': 93, '<?xml version=': 0, '>': 101, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4423935', 'n_tokens_mistral': 1681, 'n_tokens_neox': 1633, 'n_words': 518}