Skip to content

fix: Fix template README when has front-matter notation #1840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 27, 2022
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
1 change: 1 addition & 0 deletions site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"cronstrue": "2.5.0",
"dayjs": "1.11.2",
"formik": "2.2.9",
"front-matter": "4.0.2",
"history": "5.3.0",
"react": "17.0.2",
"react-dom": "17.0.2",
Expand Down
4 changes: 3 additions & 1 deletion site/src/pages/TemplatePage/TemplatePageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Link from "@material-ui/core/Link"
import { makeStyles } from "@material-ui/core/styles"
import Typography from "@material-ui/core/Typography"
import AddCircleOutline from "@material-ui/icons/AddCircleOutline"
import frontMatter from "front-matter"
import React from "react"
import ReactMarkdown from "react-markdown"
import { Link as RouterLink } from "react-router-dom"
Expand Down Expand Up @@ -33,6 +34,7 @@ export const TemplatePageView: React.FC<TemplatePageViewProps> = ({
templateResources,
}) => {
const styles = useStyles()
const readme = frontMatter(activeTemplateVersion.readme)

const getStartedResources = (resources: WorkspaceResource[]) => {
return resources.filter((resource) => resource.workspace_transition === "start")
Expand Down Expand Up @@ -74,7 +76,7 @@ export const TemplatePageView: React.FC<TemplatePageViewProps> = ({
),
}}
>
{activeTemplateVersion.readme}
{readme.body}
</ReactMarkdown>
</div>
</WorkspaceSection>
Expand Down
8 changes: 7 additions & 1 deletion site/src/testHelpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ export const MockTemplateVersion: TypesGen.TemplateVersion = {
updated_at: "",
job: MockProvisionerJob,
name: "test-version",
readme: "## Instructions\nYou can add instructions here\n\n[Some link info](https://coder.com)",
readme: `---
name:Template test
---
## Instructions
You can add instructions here

[Some link info](https://coder.com)`,
}

export const MockTemplate: TypesGen.Template = {
Expand Down
7 changes: 7 additions & 0 deletions site/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6969,6 +6969,13 @@ from2@^2.1.0:
inherits "^2.0.1"
readable-stream "^2.0.0"

front-matter@4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/front-matter/-/front-matter-4.0.2.tgz#b14e54dc745cfd7293484f3210d15ea4edd7f4d5"
integrity sha512-I8ZuJ/qG92NWX8i5x1Y8qyj3vizhXS31OxjKDu3LKP+7/qBgfIKValiZIEwoVoJKUHlhWtYrktkxV1XsX+pPlg==
dependencies:
js-yaml "^3.13.1"

fs-extra@^0.30.0:
version "0.30.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.30.0.tgz#f233ffcc08d4da7d432daa449776989db1df93f0"
Expand Down