Skip to content

Commit

Permalink
[Docs] It's building!!!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
Marten-Mrfc committed Feb 28, 2025
1 parent 9d0948b commit f2b02ca
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 36 deletions.
67 changes: 36 additions & 31 deletions documentation/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,51 +47,54 @@ const config: Config = {
locales: ['en'],
},

markdown: {
mermaid: true,
mdx1Compat: {
comments: false,
admonitions: false,
headingIds: false,
},
format: "detect",
parseFrontMatter: async (params) => {
const result = await params.defaultParseFrontMatter(params);
let author: AuthorData = {
...AUTHOR_FALLBACK,
};

// Only process if this is a blog post
if (params.filePath.includes("/devlog/")) {
// Use the authors array from front matter if available
if (result.frontMatter.authors?.[0]) {
author.username = result.frontMatter.authors[0];
markdown: {
mermaid: true,
mdx1Compat: {
comments: false,
admonitions: false,
headingIds: false,
},
format: "detect",
parseFrontMatter: async (params) => {
const result = await params.defaultParseFrontMatter(params);

// Skip author modification for blog posts - they use a different author system
if (params.filePath.includes("devlog") || params.filePath.includes("blog")) {
return result; // Return original result without modification for blog posts
}

// Get git data in production

// For versioned files and adapters, add default author info
if (params.filePath.includes("versioned_docs") || params.filePath.includes("adapters")) {
return {
...result,
frontMatter: {
...result.frontMatter,
// Add default author info to prevent "username" access errors
author: AUTHOR_FALLBACK.username
}
};
}

// Process other files as before
let authorName = AUTHOR_FALLBACK.username;

if (process.env.NODE_ENV !== "development") {
const data = await getFileCommitHashSafe(params.filePath);
if (data) {
const username = commitCache.get(data.commit);
author = {
commit: data.commit,
username: username ?? author.username ?? AUTHOR_FALLBACK.username,
};
authorName = username ?? AUTHOR_FALLBACK.username;
}
}

return {
...result,
frontMatter: {
...result.frontMatter,
authorData: author,
author: authorName // Use string value instead of object
},
};
}

return result;
},
},
},


themes: [
Expand Down Expand Up @@ -132,6 +135,8 @@ markdown: {
type: 'all',
copyright: `Copyright © ${new Date().getFullYear()} TypeWriter`,
},
showReadingTime: true,
postsPerPage: 'ALL',
},
],
[
Expand Down
9 changes: 4 additions & 5 deletions documentation/src/theme/LastUpdated/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Translate from "@docusaurus/Translate";
import { ThemeClassNames } from "@docusaurus/theme-common";
import { useDateTimeFormat } from "@docusaurus/theme-common/internal";
import { useDoc } from "@docusaurus/plugin-content-docs/client";
import type { Props } from "@theme/LastUpdated";
import Link from "@docusaurus/Link";

function LastUpdatedAtDate({ lastUpdatedAt }: { lastUpdatedAt: number }): JSX.Element {
Expand Down Expand Up @@ -80,8 +79,8 @@ export default function LastUpdated({ lastUpdatedAt, lastUpdatedBy }: Props): JS
const doc = useDoc();

const author = (doc.frontMatter as any).author as {
commit: string;
username: string;
commit?: string;
username?: string;
};

return (
Expand All @@ -91,12 +90,12 @@ export default function LastUpdated({ lastUpdatedAt, lastUpdatedBy }: Props): JS
description="The sentence used to display when a page has been last updated, and by who"
values={{
atDate: lastUpdatedAt ? <LastUpdatedAtDate lastUpdatedAt={lastUpdatedAt} /> : "",
byUser: lastUpdatedBy ? (
byUser: lastUpdatedBy && author?.username ? (
<LastUpdatedByUser lastUpdatedBy={lastUpdatedBy} username={author.username} />
) : (
""
),
inCommit: <LastUpdatedInCommit lastUpdatedIn={author.commit} />,
inCommit: author?.commit ? <LastUpdatedInCommit lastUpdatedIn={author.commit} /> : "",
}}
>
{"Last updated{atDate}{byUser}{inCommit}"}
Expand Down

0 comments on commit f2b02ca

Please # to comment.