Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Source/SuperOffice.DocsNext/ClientApp/src/pages/about.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
import { getEntry } from "astro:content";
import { render } from "astro:content";
const aboutEntry = await getEntry("contribute", "about");
const tocData = await getTocByPath('contribution');
import { getTocByPath } from "@utils/tocUtils";
import ContentLayout from "@layouts/ContentLayout.astro";

const { Content, headings } = aboutEntry ? await render(aboutEntry) : { Content: undefined, headings: [] };
---

<ContentLayout
headings={headings}
entry={aboutEntry}
toc={tocData}
TOCBasePath="contribute"
>
{Content && <Content />}
</ContentLayout
32 changes: 30 additions & 2 deletions Source/SuperOffice.DocsNext/ClientApp/src/utils/slugUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,38 @@ const contentRepo = "superoffice-docs"; // primary content repository
* For example: "external-content/superoffice-docs/docs/en/project/learn/index.md" -> "/project/learn"
*/
export function stripFilePathAndExtension(filePath: string, collection: string): string {
const base = `${contentDir}/`
return filePath.replace(base, "").replace(`${collection}/`, "").replace(/\/index/g, "").replace(/\.(md|yml|yaml)$/g, "");;
// Assumes `contentDir` is a global string like "external-content"
const escapeRegExp = (s: string) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");

// normalize backslashes -> forward slashes
let p = filePath.replace(/\\/g, "/");

// normalize base and collection (remove leading/trailing slashes)
const baseDir = contentDir.replace(/\\/g, "/").replace(/^\/+|\/+$/g, "");
const col = collection.replace(/\\/g, "/").replace(/^\/+|\/+$/g, "");

// remove leading baseDir/
if (baseDir) {
p = p.replace(new RegExp(`^${escapeRegExp(baseDir)}\/+`), "");
}

// remove leading collection/
if (col) {
p = p.replace(new RegExp(`^${escapeRegExp(col)}\/+`), "");
}

// remove trailing /index.ext (subfolder index) OR leading index.ext (collection root)
p = p.replace(/\/index\.(md|ya?ml)$/i, "");
p = p.replace(/^index\.(md|ya?ml)$/i, "");

// if still has an extension, strip it
p = p.replace(/\.(md|ya?ml)$/i, "");

// ensure leading slash; if empty -> root "/"
return p ? `/${p}` : "/";
}


/**
* Removes a known file extension (.md, .mdx, .yml, .yaml, .html) from a path.
* Logs a warning if an unknown or unsupported extension is detected.
Expand Down
2 changes: 1 addition & 1 deletion build/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ stages:
name: Default
demands:
# - agent.os -equals Linux
- Agent.ComputerName -equals tfs-build-23
- Agent.ComputerName -equals TFS-VMUX-33
steps:
# Checkout your main repo
- checkout: self
Expand Down
Loading