Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Commit 39de228

Browse files
authored
a stab at an API only version of this for the docs cutover (#698)
* a stab at an API only version of this for the docs cutover * remove the nginx docs redirect * try an nginx rewrite * remove path prefix on the gatsby side * rewrite bare /api as well * noop * /shrug * add no cache to the docker build * actually build with the prefix (thanks gatsby) * don't hard code font locations * redirect /api to /api/ and we don't care about robot SEO atm * noop * maybe we do want an api in the apiRefRoute * maybe * /shrug * just build * noop * maybe baby * the api docs are dynamically generated so any call to them needs to be rerouted to the index * /api/ back to /api * /shrug * actually this * don't build docs, just api * one more comment * Actually let's keep the docs, there are a lot of links to them atm from the api which we won't be able to redirect appropriately * hard code /docs route
1 parent cb197a6 commit 39de228

File tree

11 files changed

+88
-82
lines changed

11 files changed

+88
-82
lines changed

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ COPY plugins /app/src/plugins
3333
COPY src /app/src/src
3434

3535
ARG AMPLITUDE_KEY
36-
RUN yarn build
36+
# RUN yarn build
37+
RUN yarn build:api
3738

3839
FROM nginx:1.17
3940

4041
COPY --from=build /app/src/public /usr/share/nginx/html/new-docs/public
4142
COPY static /usr/share/nginx/html/new-docs/static
4243
COPY nginx /etc/nginx/
43-

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ TAG ?= stellar/developers:$(shell git rev-parse --short HEAD)$(and $(shell git s
77
BUILD_DATE := $(shell date -u +%FT%TZ)
88

99
docker-build:
10-
$(SUDO) docker build --pull --label org.opencontainers.image.created="$(BUILD_DATE)" \
10+
$(SUDO) docker build --no-cache --pull --label org.opencontainers.image.created="$(BUILD_DATE)" \
1111
--build-arg AMPLITUDE_KEY=$(AMPLITUDE_KEY) -t $(TAG) .
1212

1313
docker-push:

buildHelpers/createDocsPages.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ const createDocsPages = ({ actions, docs }) => {
5353
},
5454
});
5555
});
56-
const apiRefRoute = buildRoute(defaultLocale, "api");
56+
// const apiRefRoute = buildRoute(defaultLocale, "api");
57+
const apiRefRoute = buildRoute(defaultLocale);
5758
const apiRefDocIds = apiReference.map(({ childMdx }) => childMdx.id);
5859
actions.createPage({
5960
path: apiRefRoute,

gatsby-config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ module.exports = {
1919
"Stellar is an open platform for building financial products that connect people everywhere.",
2020
siteUrl: SITE_URL,
2121
},
22-
pathPrefix: "/",
22+
// pathPrefix: "/",
23+
pathPrefix: "/api",
2324
plugins: [
2425
"gatsby-transformer-sharp",
2526
"gatsby-plugin-react-helmet",

nginx/includes/server.conf

+32-35
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,46 @@
11
root /usr/share/nginx/html/new-docs/;
22

33
# FYI: Redirect breaks
4-
location = / {
5-
# `$scheme://$http_host` is because otherwise, it adds the port nginx is
6-
# listening on. Since we listen on 80 but expose 8000 by default from docker
7-
# locally, the redirect was going to `localhost/docs` which doesn't have a
8-
# server listening.
9-
return 302 $scheme://$http_host/docs;
4+
location /api {
5+
rewrite "^/api$" $scheme://$http_host/api/ permanent;
6+
rewrite "^/api/(.*)$" /$1 last;
107
}
118

129
location / {
13-
try_files /public/$uri /public/$uri/index.html /static/$uri =404;
10+
try_files /public/$uri /public/$uri/ /public/$uri/index.html /static/$uri /static/$uri/ /public/index.html =404;
1411
}
1512

1613
# explicit 301 redirects
17-
location = /software/known-issues.html {
18-
return 301 https://github.com/stellar/go/issues;
14+
location = /software/known-issues.html {
15+
return 301 https://github.com/stellar/go/issues;
1916
}
2017

2118
# .+ (vs .*) is important to avoid a redirect loop when rewriting all
2219
# non-crawler requests to `/api/`
23-
location ~* ^/api/(?<path>.+)$ {
24-
set $noJs false;
25-
set $needsCrawlerRedirect '';
20+
# location ~* ^/api/(?<path>.+)$ {
21+
# set $noJs false;
22+
# set $needsCrawlerRedirect '';
2623

27-
if ($arg_javascript = 'false') {
28-
set $noJs true;
29-
}
30-
if ($noJs = true) {
31-
rewrite ^/api/(.*) /no-js/api/$1;
32-
}
33-
if ($noJs = false) {
34-
rewrite ^/api/.*$ /api/;
35-
}
36-
# SEO optimization for API Reference. This lets crawlers only see the content
37-
# from each individual section.
38-
# UA check sourced from https://gist.github.com/thoop/8165802
39-
if ($http_user_agent ~* "googlebot|bingbot|yandex|baiduspider|twitterbot|facebookexternalhit|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest\/0\.|pinterestbot|slackbot|vkShare|W3C_Validator|whatsapp") {
40-
# Goofy variable value because nginx doesn't allow for checking multiple
41-
# conditions in an `if` block.
42-
set $needsCrawlerRedirect 'true $noJs';
43-
}
44-
# To avoid a redirect loop, we only redirect if it's not already on the no-js
45-
# request path.
46-
if ($needsCrawlerRedirect = 'true false') {
47-
return 302 $scheme://$http_host/api/$path?javascript=false;
48-
}
49-
}
24+
# if ($arg_javascript = 'false') {
25+
# set $noJs true;
26+
# }
27+
# if ($noJs = true) {
28+
# rewrite ^/api/(.*) /no-js/api/$1;
29+
# }
30+
# if ($noJs = false) {
31+
# rewrite ^/api/.*$ /api/;
32+
# }
33+
# # SEO optimization for API Reference. This lets crawlers only see the content
34+
# # from each individual section.
35+
# # UA check sourced from https://gist.github.com/thoop/8165802
36+
# if ($http_user_agent ~* "googlebot|bingbot|yandex|baiduspider|twitterbot|facebookexternalhit|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest\/0\.|pinterestbot|slackbot|vkShare|W3C_Validator|whatsapp") {
37+
# # Goofy variable value because nginx doesn't allow for checking multiple
38+
# # conditions in an `if` block.
39+
# set $needsCrawlerRedirect 'true $noJs';
40+
# }
41+
# # To avoid a redirect loop, we only redirect if it's not already on the no-js
42+
# # request path.
43+
# if ($needsCrawlerRedirect = 'true false') {
44+
# return 302 $scheme://$http_host/api/$path?javascript=false;
45+
# }
46+
# }

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"lint": "eslint --ext .js,.jsx --ignore-pattern public .",
88
"test": "jest",
99
"build": "gatsby build",
10+
"build:api": "gatsby build --prefix-paths",
1011
"clean": "gatsby clean",
1112
"check-not-master": "[ \"$(git rev-parse --abbrev-ref HEAD)\" = \"master\" ] && echo \"\\033[31mDon't commit to master\" && exit 1 || exit 0",
1213
"prod:build": "cross-env TAG=new-docs:localbuild AMPLITUDE_KEY=$AMPLITUDE_KEY make docker-build",

src/components/Documentation/LeftNav.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ export const LeftNav = ({
5151
if (topicPath === rootRelativePath) {
5252
return Object.values(articles).map((rootArticle) => (
5353
<RootItemEl key={id}>
54-
<RootLinkEl href="/docs">{rootArticle.title}</RootLinkEl>
54+
<RootLinkEl href="https://developers.stellar.org/docs">
55+
{rootArticle.title}
56+
</RootLinkEl>
5557
</RootItemEl>
5658
));
5759
}

src/components/layout/LayoutBase.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ export const LayoutBase = ({
4040
<>
4141
<Helmet
4242
link={[
43-
{ rel: "stylesheet", type: "text/css", href: "/fonts.css" },
43+
{ rel: "stylesheet", type: "text/css", href: "fonts.css" },
4444
{
4545
rel: "stylesheet",
4646
type: "text/css",
47-
href: "/docsearch-stellar.css",
47+
href: "docsearch-stellar.css",
4848
},
4949
{
5050
rel: "stylesheet",
5151
type: "text/css",
52-
href: "/autocomplete-stellar.css",
52+
href: "autocomplete-stellar.css",
5353
},
5454
]}
5555
meta={[

src/templates/ApiReference.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ const ApiReference = React.memo(function ApiReference({ data, pageContext }) {
154154
))}
155155
</NavAbsoluteEl>
156156
<AbsoluteNavFooterEl>
157-
<StyledLink href="/docs">Documentation</StyledLink>
157+
<StyledLink href="https://developers.stellar.org/docs">
158+
Documentation
159+
</StyledLink>
158160
</AbsoluteNavFooterEl>
159161
</SideNavContainer>
160162
</NavColumn>

src/templates/SingleApiReference.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ const SingleApiReference = React.memo(function ApiReference({
131131
</SingleApiSideNavContainerEl>
132132
</SideNavProgressContext.Provider>
133133
<AbsoluteNavFooterEl>
134-
<StyledLink href="/docs">Documentation</StyledLink>
134+
<StyledLink href="https://developers.stellar.org/docs">
135+
Documentation
136+
</StyledLink>
135137
</AbsoluteNavFooterEl>
136138
</NavColumn>
137139
<Column xs={9} xl={18}>

static/fonts.css

+36-36
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
font-display: block;
1616
font-family: "IBM Plex Sans";
1717
font-style: normal;
18-
src: url("/fonts/IBMPlexSans-Regular-Latin1.woff") format("woff"),
19-
url("/fonts/IBMPlexSans-Regular-Latin1.woff2") format("woff2");
18+
src: url("fonts/IBMPlexSans-Regular-Latin1.woff") format("woff"),
19+
url("fonts/IBMPlexSans-Regular-Latin1.woff2") format("woff2");
2020
font-weight: 400;
2121
unicode-range: U+0000, U+000D, U+0020-007E, U+00A0-00A3, U+00A4-00FF, U+0131,
2222
U+0152-0153, U+02C6, U+02DA, U+02DC, U+2013-2014, U+2018-201A, U+201C-201E,
@@ -28,8 +28,8 @@
2828
font-display: swap;
2929
font-family: "IBM Plex Sans";
3030
font-style: normal;
31-
src: url("/fonts/IBMPlexSans-Regular-Latin2.woff") format("woff"),
32-
url("/fonts/IBMPlexSans-Regular-Latin2.woff2") format("woff2");
31+
src: url("fonts/IBMPlexSans-Regular-Latin2.woff") format("woff"),
32+
url("fonts/IBMPlexSans-Regular-Latin2.woff2") format("woff2");
3333
font-weight: 400;
3434
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF,
3535
U+2C60-2C7F, U+A720-A7FF, U+FB01-FB02;
@@ -39,8 +39,8 @@
3939
font-display: swap;
4040
font-family: "IBM Plex Sans";
4141
font-style: normal;
42-
src: url("/fonts/IBMPlexSans-Regular-Latin3.woff") format("woff"),
43-
url("/fonts/IBMPlexSans-Regular-Latin3.woff2") format("woff2");
42+
src: url("fonts/IBMPlexSans-Regular-Latin3.woff") format("woff"),
43+
url("fonts/IBMPlexSans-Regular-Latin3.woff2") format("woff2");
4444
font-weight: 400;
4545
unicode-range: U+0102-0103, U+1EA0-1EF9, U+20AB;
4646
}
@@ -49,8 +49,8 @@
4949
font-display: block;
5050
font-family: "IBM Plex Sans";
5151
font-style: normal;
52-
src: url("/fonts/IBMPlexSans-Medium-Latin1.woff") format("woff"),
53-
url("/fonts/IBMPlexSans-Medium-Latin1.woff2") format("woff2");
52+
src: url("fonts/IBMPlexSans-Medium-Latin1.woff") format("woff"),
53+
url("fonts/IBMPlexSans-Medium-Latin1.woff2") format("woff2");
5454
font-weight: 500;
5555
unicode-range: U+0000, U+000D, U+0020-007E, U+00A0-00A3, U+00A4-00FF, U+0131,
5656
U+0152-0153, U+02C6, U+02DA, U+02DC, U+2013-2014, U+2018-201A, U+201C-201E,
@@ -62,8 +62,8 @@
6262
font-display: swap;
6363
font-family: "IBM Plex Sans";
6464
font-style: normal;
65-
src: url("/fonts/IBMPlexSans-Medium-Latin2.woff") format("woff"),
66-
url("/fonts/IBMPlexSans-Medium-Latin2.woff2") format("woff2");
65+
src: url("fonts/IBMPlexSans-Medium-Latin2.woff") format("woff"),
66+
url("fonts/IBMPlexSans-Medium-Latin2.woff2") format("woff2");
6767
font-weight: 500;
6868
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF,
6969
U+2C60-2C7F, U+A720-A7FF, U+FB01-FB02;
@@ -73,8 +73,8 @@
7373
font-display: swap;
7474
font-family: "IBM Plex Sans";
7575
font-style: normal;
76-
src: url("/fonts/IBMPlexSans-Medium-Latin3.woff") format("woff"),
77-
url("/fonts/IBMPlexSans-Medium-Latin3.woff2") format("woff2");
76+
src: url("fonts/IBMPlexSans-Medium-Latin3.woff") format("woff"),
77+
url("fonts/IBMPlexSans-Medium-Latin3.woff2") format("woff2");
7878
font-weight: 500;
7979
unicode-range: U+0102-0103, U+1EA0-1EF9, U+20AB;
8080
}
@@ -83,8 +83,8 @@
8383
font-display: swap;
8484
font-family: "IBM Plex Sans";
8585
font-style: italic;
86-
src: url("/fonts/IBMPlexSans-Italic-Latin1.woff") format("woff"),
87-
url("/fonts/IBMPlexSans-Italic-Latin1.woff2") format("woff2");
86+
src: url("fonts/IBMPlexSans-Italic-Latin1.woff") format("woff"),
87+
url("fonts/IBMPlexSans-Italic-Latin1.woff2") format("woff2");
8888
font-weight: 400;
8989
unicode-range: U+0000, U+000D, U+0020-007E, U+00A0-00A3, U+00A4-00FF, U+0131,
9090
U+0152-0153, U+02C6, U+02DA, U+02DC, U+2013-2014, U+2018-201A, U+201C-201E,
@@ -96,8 +96,8 @@
9696
font-display: swap;
9797
font-family: "IBM Plex Sans";
9898
font-style: italic;
99-
src: url("/fonts/IBMPlexSans-Italic-Latin2.woff") format("woff"),
100-
url("/fonts/IBMPlexSans-Italic-Latin2.woff2") format("woff2");
99+
src: url("fonts/IBMPlexSans-Italic-Latin2.woff") format("woff"),
100+
url("fonts/IBMPlexSans-Italic-Latin2.woff2") format("woff2");
101101
font-weight: 400;
102102
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF,
103103
U+2C60-2C7F, U+A720-A7FF, U+FB01-FB02;
@@ -107,8 +107,8 @@
107107
font-display: swap;
108108
font-family: "IBM Plex Sans";
109109
font-style: italic;
110-
src: url("/fonts/IBMPlexSans-Italic-Latin3.woff") format("woff"),
111-
url("/fonts/IBMPlexSans-Italic-Latin3.woff2") format("woff2");
110+
src: url("fonts/IBMPlexSans-Italic-Latin3.woff") format("woff"),
111+
url("fonts/IBMPlexSans-Italic-Latin3.woff2") format("woff2");
112112
font-weight: 400;
113113
unicode-range: U+0102-0103, U+1EA0-1EF9, U+20AB;
114114
}
@@ -117,8 +117,8 @@
117117
font-display: swap;
118118
font-family: "IBM Plex Sans";
119119
font-style: italic;
120-
src: url("/fonts/IBMPlexSans-MediumItalic-Latin1.woff") format("woff"),
121-
url("/fonts/IBMPlexSans-MediumItalic-Latin1.woff2") format("woff2");
120+
src: url("fonts/IBMPlexSans-MediumItalic-Latin1.woff") format("woff"),
121+
url("fonts/IBMPlexSans-MediumItalic-Latin1.woff2") format("woff2");
122122
font-weight: 500;
123123
unicode-range: U+0000, U+000D, U+0020-007E, U+00A0-00A3, U+00A4-00FF, U+0131,
124124
U+0152-0153, U+02C6, U+02DA, U+02DC, U+2013-2014, U+2018-201A, U+201C-201E,
@@ -130,8 +130,8 @@
130130
font-display: swap;
131131
font-family: "IBM Plex Sans";
132132
font-style: italic;
133-
src: url("/fonts/IBMPlexSans-MediumItalic-Latin2.woff") format("woff"),
134-
url("/fonts/IBMPlexSans-MediumItalic-Latin2.woff2") format("woff2");
133+
src: url("fonts/IBMPlexSans-MediumItalic-Latin2.woff") format("woff"),
134+
url("fonts/IBMPlexSans-MediumItalic-Latin2.woff2") format("woff2");
135135
font-weight: 500;
136136
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF,
137137
U+2C60-2C7F, U+A720-A7FF, U+FB01-FB02;
@@ -141,8 +141,8 @@
141141
font-display: swap;
142142
font-family: "IBM Plex Sans";
143143
font-style: italic;
144-
src: url("/fonts/IBMPlexSans-MediumItalic-Latin3.woff") format("woff"),
145-
url("/fonts/IBMPlexSans-MediumItalic-Latin3.woff2") format("woff2");
144+
src: url("fonts/IBMPlexSans-MediumItalic-Latin3.woff") format("woff"),
145+
url("fonts/IBMPlexSans-MediumItalic-Latin3.woff2") format("woff2");
146146
font-weight: 500;
147147
unicode-range: U+0102-0103, U+1EA0-1EF9, U+20AB;
148148
}
@@ -151,8 +151,8 @@
151151
font-display: block;
152152
font-family: "IBM Plex Mono";
153153
font-style: normal;
154-
src: url("/fonts/IBMPlexMono-Regular-Latin1.woff") format("woff"),
155-
url("/fonts/IBMPlexMono-Regular-Latin1.woff2") format("woff2");
154+
src: url("fonts/IBMPlexMono-Regular-Latin1.woff") format("woff"),
155+
url("fonts/IBMPlexMono-Regular-Latin1.woff2") format("woff2");
156156
font-weight: 400;
157157
unicode-range: U+0000, U+000D, U+0020-007E, U+00A0-00A3, U+00A4-00FF, U+0131,
158158
U+0152-0153, U+02C6, U+02DA, U+02DC, U+2013-2014, U+2018-201A, U+201C-201E,
@@ -164,8 +164,8 @@
164164
font-display: swap;
165165
font-family: "IBM Plex Mono";
166166
font-style: normal;
167-
src: url("/fonts/IBMPlexMono-Regular-Latin2.woff") format("woff"),
168-
url("/fonts/IBMPlexMono-Regular-Latin2.woff2") format("woff2");
167+
src: url("fonts/IBMPlexMono-Regular-Latin2.woff") format("woff"),
168+
url("fonts/IBMPlexMono-Regular-Latin2.woff2") format("woff2");
169169
font-weight: 400;
170170
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF,
171171
U+2C60-2C7F, U+A720-A7FF, U+FB01-FB02;
@@ -175,8 +175,8 @@
175175
font-display: swap;
176176
font-family: "IBM Plex Mono";
177177
font-style: normal;
178-
src: url("/fonts/IBMPlexMono-Regular-Latin3.woff") format("woff"),
179-
url("/fonts/IBMPlexMono-Regular-Latin3.woff2") format("woff2");
178+
src: url("fonts/IBMPlexMono-Regular-Latin3.woff") format("woff"),
179+
url("fonts/IBMPlexMono-Regular-Latin3.woff2") format("woff2");
180180
font-weight: 400;
181181
unicode-range: U+0102-0103, U+1EA0-1EF9, U+20AB;
182182
}
@@ -185,8 +185,8 @@
185185
font-display: swap;
186186
font-family: "IBM Plex Mono";
187187
font-style: normal;
188-
src: url("/fonts/IBMPlexMono-Medium-Latin1.woff") format("woff"),
189-
url("/fonts/IBMPlexMono-Medium-Latin1.woff2") format("woff2");
188+
src: url("fonts/IBMPlexMono-Medium-Latin1.woff") format("woff"),
189+
url("fonts/IBMPlexMono-Medium-Latin1.woff2") format("woff2");
190190
font-weight: 500;
191191
unicode-range: U+0000, U+000D, U+0020-007E, U+00A0-00A3, U+00A4-00FF, U+0131,
192192
U+0152-0153, U+02C6, U+02DA, U+02DC, U+2013-2014, U+2018-201A, U+201C-201E,
@@ -198,8 +198,8 @@
198198
font-display: swap;
199199
font-family: "IBM Plex Mono";
200200
font-style: normal;
201-
src: url("/fonts/IBMPlexMono-Medium-Latin2.woff") format("woff"),
202-
url("/fonts/IBMPlexMono-Medium-Latin2.woff2") format("woff2");
201+
src: url("fonts/IBMPlexMono-Medium-Latin2.woff") format("woff"),
202+
url("fonts/IBMPlexMono-Medium-Latin2.woff2") format("woff2");
203203
font-weight: 500;
204204
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF,
205205
U+2C60-2C7F, U+A720-A7FF, U+FB01-FB02;
@@ -209,8 +209,8 @@
209209
font-display: swap;
210210
font-family: "IBM Plex Mono";
211211
font-style: normal;
212-
src: url("/fonts/IBMPlexMono-Medium-Latin3.woff") format("woff"),
213-
url("/fonts/IBMPlexMono-Medium-Latin3.woff2") format("woff2");
212+
src: url("fonts/IBMPlexMono-Medium-Latin3.woff") format("woff"),
213+
url("fonts/IBMPlexMono-Medium-Latin3.woff2") format("woff2");
214214
font-weight: 500;
215215
unicode-range: U+0102-0103, U+1EA0-1EF9, U+20AB;
216216
}

0 commit comments

Comments
 (0)