Skip to content

Commit

Permalink
Improve code block styles for website
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Dec 9, 2023
1 parent fd29b74 commit a5075c7
Show file tree
Hide file tree
Showing 7 changed files with 327 additions and 175 deletions.
29 changes: 24 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"gatsby-remark-prismjs": "6.24.0",
"gatsby-source-filesystem": "4.24.0",
"http-proxy": "^1.18.1",
"prism-react-renderer": "^1.3.5",
"prism-react-renderer": "^2.3.0",
"prismjs": "^1.29.0",
"sass": "^1.55.0"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/website/root-wrapper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MDXProvider } from '@mdx-js/react';
import Highlight, { defaultProps } from 'prism-react-renderer';
import { Highlight, themes, defaultProps } from 'prism-react-renderer';
import CodePen from './src/components/CodePen';
import Editor from './src/components/Editor';
import {
Expand Down
42 changes: 21 additions & 21 deletions packages/website/src/templates/doc.jsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { useLocation } from "@reach/router";
import classNames from "classnames";
import { graphql } from "gatsby";
import SEO from "../components/SEO";
import docsItems from "../data/docs";
import guideItems from "../data/guides";
import OctocatIcon from "../svg/octocat.svg";
import slug from "../utils/slug";
import Default from "../components/Default";
import OpenSource from "../components/OpenSource";
import React, { useEffect } from "react";
import * as styles from "./doc.module.scss";
import { useLocation } from '@reach/router';
import classNames from 'classnames';
import { graphql } from 'gatsby';
import SEO from '../components/SEO';
import docsItems from '../data/docs';
import guideItems from '../data/guides';
import OctocatIcon from '../svg/octocat.svg';
import slug from '../utils/slug';
import Default from '../components/Default';
import OpenSource from '../components/OpenSource';
import React, { useEffect } from 'react';
import * as styles from './doc.module.scss';

const getPagination = (permalink, items) => {
const flattenedItems = [];

const flatItems = (i) => {
i.forEach((child) => {
if (child.url.includes("#")) return;
if (child.url.includes('#')) return;
flattenedItems.push(child);
if (child.children) {
flatItems(child.children);
Expand Down Expand Up @@ -58,16 +58,16 @@ const SidebarItem = ({ item }) => {
const Doc = ({ data, children }) => {
const { title } = data.mdx.frontmatter;
const { permalink, pageType } = data.mdx.fields;
const category = pageType === "guides" ? "Guides" : "Documentation";
const category = pageType === 'guides' ? 'Guides' : 'Documentation';

const items = pageType === "guides" ? guideItems : docsItems;
const items = pageType === 'guides' ? guideItems : docsItems;
const { prev, next } = getPagination(permalink, items);

useEffect(() => {
docsearch({
apiKey: "281facf513620e95600126795a00ab6c",
indexName: "quilljs",
inputSelector: ".search-item input",
apiKey: '281facf513620e95600126795a00ab6c',
indexName: 'quilljs',
inputSelector: '.search-item input',
debug: false,
});
}, []);
Expand All @@ -88,7 +88,7 @@ const Doc = ({ data, children }) => {
</ul>
</div>
<div id="docs-container" className="nine columns">
<div className={classNames("row", styles.breadcrumbRow)}>
<div className={classNames('row', styles.breadcrumbRow)}>
<div className={styles.breadcrumb}>
<span>{category}:</span>
<span>{title}</span>
Expand All @@ -104,10 +104,10 @@ const Doc = ({ data, children }) => {
</a>
</div>
<hr />
<div id="content-container">
<article id="content-container" className={styles.content}>
<h1 id={slug(title)}>{title}</h1>
{children}
</div>
</article>
<div className="row" id="pagination-container">
{prev && (
<a className="prev" href={prev.url}>
Expand Down
16 changes: 15 additions & 1 deletion packages/website/src/templates/doc.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

.editLink {
margin-left: auto;
font-family: "Sofia Pro", sans-serif;
font-family: 'Sofia Pro', sans-serif;
font-size: 1.08rem;
font-weight: bold;
height: 2.5em;
Expand All @@ -30,3 +30,17 @@
width: 2.5em;
}
}

.content {
code {
background: #f1f1f1;
}

pre {
border-radius: 2px;

code {
background: transparent;
}
}
}
Loading

0 comments on commit a5075c7

Please sign in to comment.