Skip to content

Commit 2e1f743

Browse files
authored
Merge branch 'main' into main-cml-pr-37b8a4fe
2 parents 53f7688 + 833f7ef commit 2e1f743

File tree

12 files changed

+256
-120
lines changed

12 files changed

+256
-120
lines changed

.github/workflows/update-commands.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Check
2525
run: |
2626
if [[ `git status packages/gatsby-theme-iterative/config/prismjs --porcelain` ]]; then
27-
cml pr create packages/gatsby-theme-iterative/config/prismjs --title "Update tool commands" --message "update tool commands"
27+
cml comment update --pr packages/gatsby-theme-iterative/config/prismjs --title "Update tool commands" --message "update tool commands"
2828
else
2929
echo "No changes!"
3030
fi

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @iterative/websites

README.md

Lines changed: 6 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,8 @@
1-
# Gatsby Theme: Iterative
1+
# Gatsby Theme: Iterative development monorepo
22

3-
This Gatsby Theme houses the shared website code for all websites for
4-
[Iterative](https://iterative.ai). This package is currently purpose-built
5-
specifically for our websites and not very useful outside of them, but we intend
6-
to change that as we make improvements and iron out issues!
3+
This repo is dedicated to the development of `gatsby-theme-iterative`, a shared
4+
code bundle used between all the Gatsby websites hosted by
5+
[Iterative, inc](iterative.ai)!
76

8-
## Usage
9-
10-
### Options
11-
12-
- disable: boolean Default: Boolean(process.env.SKIP_DOCS)
13-
14-
- getTemplate: function Default: () => defaultGetTemplate
15-
16-
- defaultTemplate: string Default: require.resolve('./src/templates/doc.tsx')
17-
18-
- remark: boolean Default: true
19-
20-
- filesystem: boolean Default: true
21-
22-
- glossaryDirectory: string Default: 'docs/user-guide/basic-concepts'
23-
24-
- simpleLinkerTerms: { matches: string, url: string }[] These terms will be
25-
passed to the simpleLinker remark plugin
26-
27-
- cssBase: string Used as base files for global PostCSS variables and queries
28-
29-
- customMediaConfig: object config passed to `postcss-custom-media`
30-
31-
- customPropertiesConfig: object config passed to `postcss-custom-properties`
32-
33-
- colorModConfig: object config passed to `postcss-color-mod`
34-
35-
- postCssPlugins: Plugin[] If specified, this array will completely replace
36-
plugins this theme passes to PostCSS. This is mostly an escape hatch for if
37-
styles are broken with the default plugins. Check out
38-
[the theme's `gatsby-config`](https://github.com/iterative/gatsby-theme-iterative/blob/main/packages/gatsby-theme-iterative/gatsby-config.js)
39-
to see the default plugins, as not having them in this option will very likely
40-
break core functionality.
41-
42-
### Examples
43-
44-
See this example from
45-
[the example website's `gatsby-config.js`](https://github.com/iterative/gatsby-theme-iterative/blob/main/packages/example/gatsby-config.js).
46-
47-
```js
48-
const path = require('path')
49-
const {
50-
name: themePackageName
51-
} = require('../gatsby-theme-iterative/package.json')
52-
53-
module.exports = {
54-
trailingSlash: 'never',
55-
siteMetadata: {
56-
title: 'Example website',
57-
description: 'Example website description',
58-
keywords: ['docs', 'test'],
59-
siteUrl: 'http://localhost:8000'
60-
},
61-
plugins: [
62-
{
63-
resolve: themePackageName,
64-
options: {
65-
simpleLinkerTerms: require('./content/linked-terms')
66-
}
67-
},
68-
{
69-
resolve: 'gatsby-source-filesystem',
70-
options: {
71-
name: 'images',
72-
path: path.join(__dirname, 'static', 'img')
73-
}
74-
},
75-
'@sentry/gatsby'
76-
]
77-
}
78-
```
7+
For more details about the theme itself, check out its
8+
[README](packages/gatsby-theme-iterative/README.md)!

packages/example/gatsby-config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ module.exports = {
99
title: 'Example website',
1010
description: 'Example website description',
1111
keywords: ['docs', 'test'],
12-
siteUrl: 'http://localhost:8000'
12+
siteUrl: 'http://gatsby-theme-iterative-example.herokuapp.com'
1313
},
1414
plugins: [
1515
{
1616
resolve: themePackageName,
1717
options: {
18-
simpleLinkerTerms: require('./content/linked-terms')
18+
simpleLinkerTerms: require('./content/linked-terms'),
19+
plausibleSrc: null
1920
}
2021
},
2122
{
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# Gatsby Theme: Iterative
2+
3+
This Gatsby theme is what [Iterative, inc.](https://iterative.ai) uses to power
4+
all of our Gatsby websites! It contains all of our shared utility code, as well
5+
as our full docs engine. This project is still evolving, and while it's
6+
currently very specific to iterative.ai websites we hope to make it usable for
7+
others in the future.
8+
9+
## Usage
10+
11+
### Options
12+
13+
- disable: boolean
14+
15+
Default: Boolean(process.env.SKIP_DOCS)
16+
17+
Stops this theme from making pages. Could be used as a conditional for test
18+
and development purposes.
19+
20+
- defaultTemplate: string
21+
22+
Default: require.resolve('./src/templates/doc.tsx')
23+
24+
Will be passed to the `getTemplate` function to use as a default template, the
25+
default function simply returns this if `template` isn't specified.
26+
27+
- getTemplate: function
28+
29+
Default:
30+
31+
```ts
32+
const defaultGetTemplate = (template, defaultTemplate) =>
33+
template
34+
? require.resolve(path.resolve('src', 'templates', template + '.tsx'))
35+
: defaultTemplate
36+
```
37+
38+
This function will be given the `template` field specified in the page's
39+
frontmatter, as well as the `defaultTemplate` specified by the option above.
40+
It is expected to return the absolute path to a React component to be given to
41+
Gatsby's `createPage` action.
42+
43+
- remark: boolean
44+
45+
Default: true
46+
47+
if true, this theme will add its own instance of `gatsby-transformer-remark`.
48+
49+
- filesystem: boolean
50+
51+
Default: true
52+
53+
if true, this theme will add its own instance of `gatsby-source-filesystem`.
54+
55+
- glossaryPath: string
56+
57+
Default: path.resolve('content', 'docs', 'user-guide', 'basic-concepts')
58+
59+
- simpleLinkerTerms: { matches: string, url: string }[]
60+
61+
Default: undefined
62+
63+
These terms will be passed to `plugins/gatsby-remark-dvc-linker`, which will
64+
scan code blocks for ones with content matching `matches`, and then link it to
65+
that entry's `url`.
66+
67+
- postCssPlugins: Plugin[]
68+
69+
Default:
70+
71+
```js
72+
const postCssPlugins = [
73+
require('tailwindcss/nesting')(require('postcss-nested')),
74+
autoprefixer,
75+
require('tailwindcss')
76+
]
77+
```
78+
79+
If specified, this array will completely replace plugins this theme passes to
80+
PostCSS. This is mostly an escape hatch for if styles are broken with the
81+
default plugins. Check out
82+
[the theme's `gatsby-config`](https://github.com/iterative/gatsby-theme-iterative/blob/main/packages/gatsby-theme-iterative/gatsby-config.js)
83+
to see the default plugins, as not having them in this option will very likely
84+
break core functionality.
85+
86+
- docsInstanceName: string
87+
88+
Default: 'iterative-docs'
89+
90+
The `name` that will be passed to the `gatsby-source-filesystem` instance for
91+
docs pages. The resulting `sourceInstanceName` will be used to identify files
92+
that will be processed as docs pages.
93+
94+
- docsPath: string
95+
96+
Default: path.resolve('content', 'docs')
97+
98+
- glossaryInstanceName: string
99+
100+
Default: 'iterative-glossary'
101+
102+
The `name` that will be passed to the `gatsby-source-filesystem` instance for
103+
glossary entries. The resulting `sourceInstanceName` will be used to identify
104+
files that will be processed as glossary pages.
105+
106+
- argsLinkerPath: string
107+
108+
Default: ['command-reference', `ref`, 'cli-reference']
109+
110+
The path that `plugins/gatsby-remark-args-linker` will operate on, connecting
111+
arguments listed in the summary with their summaries deeper in the page.
112+
113+
- docsPrefix: string
114+
115+
Default: 'doc'
116+
117+
This is the prefix that the docs pages will render to, including the index
118+
page at the exact path.
119+
120+
### Examples
121+
122+
See this example from
123+
[the example website's `gatsby-config.js`](https://github.com/iterative/gatsby-theme-iterative/blob/main/packages/example/gatsby-config.js).
124+
125+
```js
126+
const path = require('path')
127+
const {
128+
name: themePackageName
129+
} = require('../gatsby-theme-iterative/package.json')
130+
131+
module.exports = {
132+
trailingSlash: 'never',
133+
siteMetadata: {
134+
title: 'Example website',
135+
description: 'Example website description',
136+
keywords: ['docs', 'test'],
137+
siteUrl: 'http://localhost:8000'
138+
},
139+
plugins: [
140+
{
141+
resolve: themePackageName,
142+
options: {
143+
simpleLinkerTerms: require('./content/linked-terms')
144+
}
145+
},
146+
{
147+
resolve: 'gatsby-source-filesystem',
148+
options: {
149+
name: 'images',
150+
path: path.join(__dirname, 'static', 'img')
151+
}
152+
},
153+
'@sentry/gatsby'
154+
]
155+
}
156+
```
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
const path = require('path')
2+
23
module.exports = {
3-
glossaryPath: path.resolve('content', 'docs', 'user-guide', 'basic-concepts'),
44
docsPath: path.resolve('content', 'docs'),
5-
glossaryInstanceName: 'iterative-glossary',
65
docsInstanceName: 'iterative-docs',
6+
glossaryPath: path.resolve('content', 'docs', 'user-guide', 'basic-concepts'),
7+
glossaryInstanceName: 'iterative-glossary',
78
argsLinkerPath: ['command-reference', `ref`, 'cli-reference']
89
}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ const defaults = require('./config-defaults')
2020

2121
module.exports = ({
2222
simpleLinkerTerms,
23+
plausibleSrc = '/pl/js/plausible.outbound-links.js',
24+
plausibleAPI = '/pl/api/event',
25+
plausibleDomain,
2326
postCssPlugins = [
2427
require('tailwindcss/nesting')(require('postcss-nested')),
2528
autoprefixer,
@@ -154,7 +157,9 @@ module.exports = ({
154157
].filter(Boolean),
155158
siteMetadata: {
156159
author: 'Iterative',
157-
siteUrl: 'https://example.com',
158-
titleTemplate: ''
160+
titleTemplate: '',
161+
plausibleSrc,
162+
plausibleAPI,
163+
plausibleDomain
159164
}
160165
})

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ exports.pluginOptionsSchema = ({ Joi }) => {
1616
),
1717
remark: Joi.boolean().default(true),
1818
filesystem: Joi.boolean().default(true),
19-
glossaryDirectory: Joi.string().default(
19+
glossaryPath: Joi.string().default(
2020
path.resolve('content', 'docs', 'user-guide', 'basic-concepts')
2121
),
2222
docsDirectory: Joi.string().default(path.resolve('content', 'docs')),
@@ -29,12 +29,13 @@ exports.pluginOptionsSchema = ({ Joi }) => {
2929
url: Joi.string()
3030
})
3131
),
32-
cssBase: Joi.string(),
33-
customMediaConfig: Joi.object(),
3432
postCssPlugins: Joi.array(),
3533
argsLinkerPath: Joi.alternatives()
3634
.try(Joi.string(), Joi.array().items(Joi.string()))
37-
.default(defaults.argsLinkerPath)
35+
.default(defaults.argsLinkerPath),
36+
plausibleSrc: [Joi.string().optional(), Joi.allow(null)],
37+
plausibleAPI: [Joi.string().optional(), Joi.allow(null)],
38+
plausibleDomain: [Joi.string().optional(), Joi.allow(null)]
3839
})
3940
}
4041

@@ -65,6 +66,17 @@ exports.createSchemaCustomization = async api => {
6566
name: 'String!',
6667
match: '[String]'
6768
}
69+
}),
70+
buildObjectType({
71+
name: 'SiteSiteMetadata',
72+
fields: {
73+
author: 'String',
74+
siteUrl: 'String',
75+
titleTemplate: 'String',
76+
plausibleSrc: 'String',
77+
plausibleDomain: 'String',
78+
plausibleAPI: 'String'
79+
}
6880
})
6981
])
7082
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* eslint-env node */
2+
const React = require('react')
3+
4+
const onRenderBody = ({ setHeadComponents }, { plausibleSrc }) => {
5+
if (plausibleSrc) {
6+
return setHeadComponents([
7+
<script
8+
key="plausible-custom-events"
9+
dangerouslySetInnerHTML={{
10+
__html:
11+
'window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }'
12+
}}
13+
/>
14+
])
15+
}
16+
}
17+
18+
exports.onRenderBody = onRenderBody

packages/gatsby-theme-iterative/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dvcorg/gatsby-theme-iterative",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "",
55
"main": "index.js",
66
"types": "src/typings.d.ts",

0 commit comments

Comments
 (0)