Skip to content

Commit 2bb4003

Browse files
Refactor and simplify styles and templates (#33)
* Update packages and use Script component * Add requirements for nginx buildpack * Add script that cleans all but necessary files after build * Fix(?) heroku script * Remove script and just point nginx at path * Make main layout body expand to full height * Add new homepage * Replace postcss media and mixins with tailwind equivalents * Improve layout and remove postcss media in JS * Remove color mod and custom properties, replace headerIsScrolled * Change how intersection observer is used to check for scrolled header * Move docs left toggle menu one z-index higher so it shows on super small screens * Change layout to flex-based one that doesn't require advanced scroll handling * Fix eslint * Add forced scroll height to homepage and use sentinel to collapse flex header * Make slightly better homepage * Upgrade again * Move plausible script outside of Helmet * Remove unused import * Remove unused cssBase * Update packages * Remove template wrapping system * Upgrade packages * Upgrade packages * Remove unused files * Add rewrite rule for trailing slashes on the example server * Try just disabling trailingSlash * Fix root * Remove useRedirect * Try another nginx rule * Use try_files * Fix link styling by using our custom link component * Update packages * Use @sentry/gatsby * Remove DEV_SSR plugin * Use example URL and make max breakpoints unique placeholders * re-remove sentry * Use classNames in long tailwind utility classes * Fix right sidebar top margin * Tweak styles, fixing external link icon * Make docs engine more configurable * Try one way of fixing the header * Refactor layout to fix some height, alert, and header bugs * Fix scroll-past-the-end bug? * Revert to flex sticky header and add padding * Fix header social icons * Fix scroll-past-header bug and refactor header links * Add simpler method for hiding nav items * Ensure docs first h1 and right bar "content" header are aligned particularly while not breaking mobile * use scroll-margin-top for anchor nav * Add margin:auto to home container * Refactor sidebar autoscrolling * Increase specificity of markdown list style rules * Fix sticky sidebars * Fix mobile sidebar scrolling * Use fixed header and sticky sidebar to fix issues * Retweak padding and width of sidebar * Use max height so sidebar isn't necessarily size of screen * Tweak layout so docs look better at all heights * Make right sidebar screen-height and sticky * Reposition sidebar back in line with header * Fix mobile sidebar and content by adding explicit width * Fix args linker and make its targeted pages configurable * Shift 10px of margin to right panel so buttons block has its own spacing * Only add horizontal padding to markdown content after xs * use pathname instead of slug * v0.2.0 Co-authored-by: Thomas Kunwar <[email protected]>
1 parent e4bc52f commit 2bb4003

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1477
-2436
lines changed

packages/example/src/pages/index.tsx

+34-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,39 @@
11
import React from 'react'
2-
import { Link } from 'gatsby'
2+
import cn from 'classnames'
3+
import { PageProps } from 'gatsby'
4+
import MainLayout from '@dvcorg/gatsby-theme-iterative/src/components/MainLayout'
5+
import Link from '@dvcorg/gatsby-theme-iterative/src/components/Link'
36

4-
export default function Home() {
7+
export default function Home({ location }: PageProps) {
58
return (
6-
<div>
7-
<h1>Gatsby Theme: Iterative</h1>
8-
<p>
9-
Welcome to the documentation and example website for Iterative&apos;s
10-
website engine!
11-
</p>
12-
<p>
13-
This theme is primarily related to adding a documentation engine, which
14-
you can see <Link to="/doc">here!</Link>
15-
</p>
16-
</div>
9+
<MainLayout location={location}>
10+
<div
11+
className={cn(
12+
'container',
13+
'mx-auto',
14+
'mt-14',
15+
'px-4',
16+
'py-14',
17+
'flex',
18+
'flex-col',
19+
'justify-center',
20+
'items-center'
21+
)}
22+
>
23+
<h1 className={cn('text-2xl', 'font-bold', 'text-center', 'mb-5')}>
24+
Gatsby Theme: Iterative
25+
</h1>
26+
<section className="text-lg">
27+
<p>
28+
Welcome to the documentation and example website for
29+
Iterative&apos;s website engine!
30+
</p>
31+
<p>
32+
This theme is primarily related to adding a documentation engine,
33+
which you can see <Link href="/doc">here!</Link>
34+
</p>
35+
</section>
36+
</div>
37+
</MainLayout>
1738
)
1839
}

packages/example/tailwind.config.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
const themeConfig = require('@dvcorg/gatsby-theme-iterative/tailwind.config')
2+
13
module.exports = {
2-
content: ['./src/**/*.{js,jsx,ts,tsx}'],
4+
...themeConfig,
5+
content: [...themeConfig.content, './src/**/*'],
36
theme: {
4-
extend: {}
5-
},
6-
plugins: []
7+
...themeConfig.theme,
8+
fontFamily: {
9+
sans: ['Tahoma', 'Arial', 'sans-serif'],
10+
mono: ['Consolas', '"Liberation Mono"', 'Menlo', 'Courier', 'monospace']
11+
}
12+
}
713
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const path = require('path')
2+
module.exports = {
3+
glossaryPath: path.resolve('content', 'docs', 'user-guide', 'basic-concepts'),
4+
docsPath: path.resolve('content', 'docs'),
5+
glossaryInstanceName: 'iterative-glossary',
6+
docsInstanceName: 'iterative-docs',
7+
argsLinkerPath: ['command-reference', `ref`, 'cli-reference']
8+
}

packages/gatsby-theme-iterative/config/postcss/media.d.ts

-2
This file was deleted.

packages/gatsby-theme-iterative/config/postcss/media.js

-19
This file was deleted.

packages/gatsby-theme-iterative/config/postcss/mixins.js

-115
This file was deleted.

packages/gatsby-theme-iterative/createPages.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const GithubSlugger = require('github-slugger')
33
const slugger = new GithubSlugger()
44
const SLUG_REGEXP = /\s+{#([a-z0-9-]*[a-z0-9]+)}\s*$/
55

6+
const path = require('path')
7+
68
const extractSlugFromTitle = title => {
79
// extracts expressions like {#too-many-files} from the end of a title
810
const meta = title.match(SLUG_REGEXP)
@@ -34,7 +36,7 @@ const parseHeadings = text => {
3436

3537
const createPages = async (
3638
{ graphql, actions },
37-
{ defaultTemplate, getTemplate, disable }
39+
{ defaultTemplate, getTemplate, disable, docsPrefix }
3840
) => {
3941
if (disable) return
4042
const docsResponse = await graphql(
@@ -73,14 +75,13 @@ const createPages = async (
7375
} = doc
7476
const headings = parseHeadings(rawMarkdownBody)
7577

76-
if (slug) {
78+
if (slug !== undefined) {
7779
actions.createPage({
7880
component: getTemplate(template, defaultTemplate),
79-
path: slug,
81+
path: path.posix.join(docsPrefix, slug),
8082
context: {
8183
id,
8284
slug,
83-
isDocs: true,
8485
headings
8586
}
8687
})

packages/gatsby-theme-iterative/gatsby-browser.js

-3
This file was deleted.

packages/gatsby-theme-iterative/gatsby-config.js

+21-39
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,6 @@ const fs = require('fs')
33
const path = require('path')
44

55
const autoprefixer = require('autoprefixer')
6-
const customMedia = require('postcss-custom-media')
7-
const customProperties = require('postcss-custom-properties')
8-
const mixins = require('postcss-mixins')
9-
const colorMod = require('postcss-color-mod-function')
10-
11-
const mediaConfig = require('./config/postcss/media')
12-
const mixinsConfig = require('./config/postcss/mixins')
13-
14-
const defaultCssBase = path.join(
15-
__dirname,
16-
'src',
17-
'components',
18-
'Page',
19-
'base.css'
20-
)
216

227
const customYoutubeTransformer = require('./config/gatsby-remark-embedder/custom-yt-embedder')
238

@@ -31,26 +16,20 @@ require('./config/prismjs/dvctable')
3116

3217
const imageMaxWidth = 700
3318

19+
const defaults = require('./config-defaults')
20+
3421
module.exports = ({
3522
simpleLinkerTerms,
36-
cssBase = defaultCssBase,
37-
customMediaConfig = { importFrom: [mediaConfig] },
38-
customPropertiesConfig = {
39-
importFrom: [cssBase],
40-
disableDeprecationNotice: true
41-
},
42-
colorModConfig = {
43-
importFrom: [cssBase]
44-
},
4523
postCssPlugins = [
4624
require('tailwindcss/nesting')(require('postcss-nested')),
47-
customMedia(customMediaConfig),
48-
mixins(mixinsConfig),
49-
customProperties(customPropertiesConfig),
50-
colorMod(colorModConfig),
5125
autoprefixer,
5226
require('tailwindcss')
53-
]
27+
],
28+
docsInstanceName = defaults.docsInstanceName,
29+
docsPath = defaults.docsPath,
30+
glossaryInstanceName = defaults.glossaryInstanceName,
31+
glossaryPath = defaults.glossaryPath,
32+
argsLinkerPath = defaults.argsLinkerPath
5433
}) => ({
5534
plugins: [
5635
{
@@ -68,11 +47,18 @@ module.exports = ({
6847
},
6948
'gatsby-plugin-react-helmet',
7049
'gatsby-plugin-sitemap',
71-
{
50+
glossaryInstanceName && {
7251
resolve: 'gatsby-source-filesystem',
7352
options: {
74-
name: 'content',
75-
path: path.resolve('content')
53+
name: glossaryInstanceName,
54+
path: glossaryPath
55+
}
56+
},
57+
docsInstanceName && {
58+
resolve: 'gatsby-source-filesystem',
59+
options: {
60+
name: docsInstanceName,
61+
path: docsPath
7662
}
7763
},
7864
'gatsby-plugin-image',
@@ -97,11 +83,7 @@ module.exports = ({
9783
options: {
9884
icon: linkIcon,
9985
// Pathname can also be array of paths. eg: ['docs/command-reference;', 'docs/api']
100-
pathname: [
101-
'docs/command-reference',
102-
`docs/ref`,
103-
'docs/cli-reference'
104-
]
86+
pathname: argsLinkerPath
10587
}
10688
},
10789
{
@@ -169,10 +151,10 @@ module.exports = ({
169151
}
170152
}
171153
}
172-
],
154+
].filter(Boolean),
173155
siteMetadata: {
174156
author: 'Iterative',
175-
siteUrl: 'https://cml.dev',
157+
siteUrl: 'https://example.com',
176158
titleTemplate: ''
177159
}
178160
})

packages/gatsby-theme-iterative/gatsby-node.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const path = require('path')
22
const { name: packageName } = require('./package.json')
3+
const defaults = require('./config-defaults')
34

45
const defaultGetTemplate = (template, defaultTemplate) =>
56
template
@@ -15,7 +16,13 @@ exports.pluginOptionsSchema = ({ Joi }) => {
1516
),
1617
remark: Joi.boolean().default(true),
1718
filesystem: Joi.boolean().default(true),
18-
glossaryDirectory: Joi.string().default('docs/user-guide/basic-concepts'),
19+
glossaryDirectory: Joi.string().default(
20+
path.resolve('content', 'docs', 'user-guide', 'basic-concepts')
21+
),
22+
docsDirectory: Joi.string().default(path.resolve('content', 'docs')),
23+
glossaryInstanceName: Joi.string().default('iterative-glossary'),
24+
docsInstanceName: Joi.string().default('iterative-docs'),
25+
docsPrefix: Joi.string().default('doc'),
1926
simpleLinkerTerms: Joi.array().items(
2027
Joi.object({
2128
matches: Joi.string(),
@@ -24,9 +31,10 @@ exports.pluginOptionsSchema = ({ Joi }) => {
2431
),
2532
cssBase: Joi.string(),
2633
customMediaConfig: Joi.object(),
27-
customPropertiesConfig: Joi.object(),
28-
colorModConfig: Joi.object(),
29-
postCssPlugins: Joi.array()
34+
postCssPlugins: Joi.array(),
35+
argsLinkerPath: Joi.alternatives()
36+
.try(Joi.string(), Joi.array().items(Joi.string()))
37+
.default(defaults.argsLinkerPath)
3038
})
3139
}
3240

0 commit comments

Comments
 (0)