Skip to content

Commit

Permalink
fix(renderer): update md rendering #159
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-capsule42 committed Feb 26, 2024
1 parent 097793b commit fb440be
Show file tree
Hide file tree
Showing 72 changed files with 2,177 additions and 3,546 deletions.
4,370 changes: 1,616 additions & 2,754 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"@aurodesignsystem/design-tokens": "^4.3.1",
"@aurodesignsystem/webcorestylesheets": "^5.0.8",
"@aurolabs/auro-back-to-top": "^1.1.0",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@commitlint/cli": "^18.4.4",
"@commitlint/config-conventional": "^18.4.4",
"@webcomponents/webcomponentsjs": "^2.8.0",
"apollo-boost": "^0.4.9",
"axios": "^0.27.2",
Expand Down Expand Up @@ -76,8 +76,7 @@
"devDependencies": {
"@aurodesignsystem/auro-tokenlist": "^1.2.0",
"copyfiles": "^2.4.1",
"marked": "^2.1.3",
"npm-check": "^5.9.2",
"marked": "^11.0.0",
"npm-run-all": "^4.1.5",
"prismjs": "^1.29.0",
"react-markdown": "^4.3.1",
Expand Down
2 changes: 1 addition & 1 deletion src/components/linkIcons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function LinkIcons(props) {
function npm() {
if (props.npm) {
return (
<a href={props.npm} target="_blank" rel="noopener noreferrer" aria-label="Install npm pachage">
<a href={props.npm} target="_blank" rel="noopener noreferrer" aria-label="Install npm package">
<Npm role="img" aria-hidden="false" />
</a>
)
Expand Down
2 changes: 1 addition & 1 deletion src/content/dynamic/_template/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Auro[component] extends MarkdownPageWrapper {
fetch(markdownContent)
.then((response) => response.text())
.then((text) => {
const rawHtml = marked(text);
const rawHtml = marked.parse(text);
document.querySelector('.auro-markdown').innerHTML = rawHtml;
Prism.highlightAll();
});
Expand Down
41 changes: 7 additions & 34 deletions src/content/dynamic/accordion/api.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,12 @@
import React from "react";
import { Nav } from './nav';
import ReactMarkdown from 'react-markdown';
import CodeBlock from 'components/CodeBlock';
import { MarkdownPageWrapper } from 'components/markdownPageWrapper';
import AuroComponentContent from "functions/renderContentPage";

const markdownContent = 'https://raw.githubusercontent.com/AlaskaAirlines/auro-accordion/main/demo/api.md';
class AuroContent extends AuroComponentContent {

class AuroAccordionApi extends MarkdownPageWrapper {
constructor(props) {
super(props);

componentWillMount() {
fetch(markdownContent).then((response) => response.text()).then((text) => {
this.setState({
contentBuild: text
})
})
}

render() {
return (
<section className="auro_baseType">

<Nav />

<section className="auro-markdown">
<ReactMarkdown
source={this.state.contentBuild}
escapeHtml={false}
renderers={{
code: CodeBlock,
heading: this.headingRenderer
}}/>
</section>
</section>
);
}
this.markdownContent = 'https://raw.githubusercontent.com/AlaskaAirlines/auro-accordion/main/demo/api.md';
};
}

export default AuroAccordionApi;
export default AuroContent;
66 changes: 7 additions & 59 deletions src/content/dynamic/accordion/component.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,12 @@
import React from "react";
import { Nav } from './nav';
import marked from 'marked';
import Prism from 'prismjs';
import 'prismjs/themes/prism.css';
import { MarkdownPageWrapper } from 'components/markdownPageWrapper';
import { registerCustomComponent } from "content/utils/registerCustomComponent";
import AuroComponentContent from "functions/renderContentPage";

const markdownContent = 'https://raw.githubusercontent.com/AlaskaAirlines/auro-accordion/main/demo/demo.md';
class AuroContent extends AuroComponentContent {

class AuroAccordionComponent extends MarkdownPageWrapper {
constructor(props) {
super(props);

// function to get text from MD document
getMarkdownText() {
fetch(markdownContent)
.then((response) => response.text())
.then((text) => {
const rawHtml = marked(text);
document.querySelector('.auro-markdown').innerHTML = rawHtml;
Prism.highlightAll();
});

const renderer = new marked.Renderer();
renderer.link = function(href, title, text) {
const link = marked.Renderer.prototype.link.call(this, href, title, text);
let url = href
url = url.replace(/^.*\/\/[^/]+/, '')

if (href.includes("auro.alaskaair.com")) {

return link.replace("href",`href="${url}"`);
} else {

const newLink = `<a href="${href}" rel="noopener noreferrer" target="_blank" className="externalLink">${text} <auro-icon customColor category="interface" name="external-link-md"></auro-icon></a>`

return newLink;
}
};

marked.setOptions({
renderer: renderer
});
}

componentDidMount() {
registerCustomComponent('custom-accordion', 'https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-accordion@latest/dist/auro-accordion__bundled.js');
}

render() {
return (
<section className="auro_baseType">

<Nav />

<section
className="auro-markdown"
dangerouslySetInnerHTML={this.getMarkdownText()}
/>
</section>
);
}
this.markdownContent = 'https://raw.githubusercontent.com/AlaskaAirlines/auro-accordion/main/demo/demo.md';
};
}

export default AuroAccordionComponent;
export default AuroContent;
47 changes: 6 additions & 41 deletions src/content/dynamic/accordion/install.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,12 @@
import React from "react";
import { Nav } from './nav';
import ReactMarkdown from 'react-markdown';
import CodeBlock from 'components/CodeBlock';
import { MarkdownPageWrapper } from 'components/markdownPageWrapper';
import AuroComponentContent from "functions/renderContentPage";

const markdownContent = 'https://raw.githubusercontent.com/AlaskaAirlines/auro-accordion/main/README.md';
class AuroContent extends AuroComponentContent {

class AuroAccordionInstall extends MarkdownPageWrapper {
showVersion() {
const pjson = require('../../../../package.json');
const dependencies = pjson.dependencies['@alaskaairux/auro-accordion'];
constructor(props) {
super(props);

return `@alaskaairux/auro-accordion: ${dependencies}`;
this.markdownContent = 'https://raw.githubusercontent.com/AlaskaAirlines/auro-accordion/main/README.md';
};

// function to get text from MD document
componentWillMount() {
fetch(markdownContent).then((response) => response.text()).then((text) => {
this.setState({
contentBuild: text
})
})
}

render() {
return (
<section className="auro_baseType">

<Nav />

<section className="auro-markdown">
<ReactMarkdown
source={this.state.contentBuild}
escapeHtml={false}
renderers={{
code: CodeBlock,
heading: this.headingRenderer,
link: this.linkRenderer
}}/>
</section>
</section>
);
}
}

export default AuroAccordionInstall;
export default AuroContent;
23 changes: 0 additions & 23 deletions src/content/dynamic/accordion/nav.js

This file was deleted.

57 changes: 7 additions & 50 deletions src/content/dynamic/accordion/releases.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,12 @@
import React, { Component } from "react";
import { Query } from '@apollo/react-components';
import { gql } from 'apollo-boost';
import Releases from '../releaseDashboard/releases';
import { Nav } from './nav';
import AuroComponentContent from "functions/renderContentPage";

const RELEASES = gql`
{
organization(login: "AlaskaAirlines") {
team(slug: "auro-team") {
repositories(first: 1, orderBy: {field: NAME, direction: ASC}, query: "auro-accordion") {
nodes {
name
releases(first: 20, orderBy: {field: CREATED_AT, direction: DESC}) {
nodes {
name
updatedAt
description
}
}
}
}
}
}
}
`

class AllReleases extends Component {
render() {
return (
<section id="releases">

<Nav />

<h1 className="auro_heading auro_heading--display">Releases</h1>
<p>The following is a list of all Auro element releases.</p>
class AuroContent extends AuroComponentContent {

<Query query={RELEASES}>
{({ loading, error, data }) => {
if (loading) return <auro-loader laser onlight></auro-loader>;
if (error) return <p>We are unable to connect to GitHub at the moment, please try back later.</p>;
constructor(props) {
super(props);

return data.organization.team.repositories.nodes.map(({ name, releases }) => (
releases.nodes.length > 0
? <Releases key={name} name={name} releases={releases.nodes} />
: ''
));
}}
</Query>
</section>
)
}
this.hasFigma = false;
};
}

export default AllReleases;
export default AuroContent;
43 changes: 9 additions & 34 deletions src/content/dynamic/alert/api.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,14 @@
import React from "react";
import { Nav } from './nav';
import ReactMarkdown from 'react-markdown';
import CodeBlock from 'components/CodeBlock';
import { MarkdownPageWrapper } from 'components/markdownPageWrapper';
import AuroComponentContent from "functions/renderContentPage";

const markdownContent = 'https://raw.githubusercontent.com/AlaskaAirlines/auro-alert/main/demo/api.md';
class AuroContent extends AuroComponentContent {

class AuroAlertApi extends MarkdownPageWrapper {
constructor(props) {
super(props);

componentWillMount() {
fetch(markdownContent).then((response) => response.text()).then((text) => {
this.setState({
contentBuild: text
})
})
}

render() {
return (
<section className="auro_baseType">

<Nav />

<section className="auro-markdown">
<ReactMarkdown
source={this.state.contentBuild}
escapeHtml={false}
renderers={{
code: CodeBlock,
heading: this.headingRenderer
}}/>
</section>
</section>
);
}
this.nameSpace = 'aurodesignsystem';
this.componentName = 'alert';
this.markdownContent = 'https://raw.githubusercontent.com/AlaskaAirlines/auro-alerts/master/docs/api.md';
};
}

export default AuroAlertApi;
export default AuroContent;
Loading

0 comments on commit fb440be

Please sign in to comment.