Add internaldocs-fb-helpers lib
Summary: This adds a new npm package "internaldocs-fb-helpers", and shows example usage in the flipper package. This will stop everyone from having to inline the function definitions everywhere as is currently the case. (It's using the old internaldocs name, to match the existing docusaurus-plugin-internaldocs-fb package - I don't think that's a big deal.) It currently exports two methods: * `fbContent(internalContent, publicContent)` * Allows you to return internal or external content based on build variant. * Has named args so you don't accidentally put internal stuff in the external arg. * `isInternal(): boolean` * Not strictly necessary, but helps if you want to write your docs using an boolean variable rather than a switching function every time. * `fbInternalOnly(internalContent)` * Convenience method for when you want internal content, or nothing. I could have put these inside the existing docusaurus plugin, but that has docu v2 as a peer dependency, and I want these helpers to work on v1 as well, so made it a standalone package. Reviewed By: passy Differential Revision: D23474462 fbshipit-source-id: 22e5be6de2f3233deb298f1542a06e3575b6555a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d4d2937c80
commit
f33d4b3f9e
@@ -6,24 +6,23 @@
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
function FBInternalWithOssFallback(elements, fallback) {
|
||||
return process.env.FB_INTERNAL ? elements : fallback;
|
||||
}
|
||||
|
||||
const {fbContent, fbInternalOnly} = require('internaldocs-fb-helpers');
|
||||
|
||||
const repoUrl = 'https://github.com/facebook/flipper';
|
||||
const siteConfig = {
|
||||
title: FBInternalWithOssFallback('Flipper @FB', 'Flipper'),
|
||||
title: fbContent({internal: 'Flipper @FB', external: 'Flipper'}),
|
||||
tagline: 'Extensible mobile app debugging',
|
||||
url: FBInternalWithOssFallback(
|
||||
'https://flipper.thefacebook.com/',
|
||||
'https://fbflipper.com/',
|
||||
),
|
||||
url: fbContent({
|
||||
internal: 'https://flipper.thefacebook.com/',
|
||||
external: 'https://fbflipper.com/',
|
||||
}),
|
||||
baseUrl: '/',
|
||||
projectName: 'flipper',
|
||||
// TODO: T69061026 enable once sandy docs are complete: external_domain: 'fbflipper.com',
|
||||
themeConfig: {
|
||||
navbar: {
|
||||
title: FBInternalWithOssFallback('Flipper @FB', 'Flipper'),
|
||||
title: fbContent({internal: 'Flipper @FB', external: 'Flipper'}),
|
||||
logo: {
|
||||
alt: 'Flipper Logo',
|
||||
src: 'img/icon.png',
|
||||
@@ -49,7 +48,7 @@ const siteConfig = {
|
||||
label: 'GitHub',
|
||||
position: 'right',
|
||||
},
|
||||
...FBInternalOnly([
|
||||
...fbInternalOnly([
|
||||
{
|
||||
to: 'docs/fb/index',
|
||||
label: 'FB Internal',
|
||||
@@ -127,11 +126,14 @@ const siteConfig = {
|
||||
src: 'img/mascot.png',
|
||||
},
|
||||
},
|
||||
algolia: FBInternalWithOssFallback(undefined, {
|
||||
apiKey: '2df980e7ffc95c19552790f7cad32666',
|
||||
indexName: 'fbflipper',
|
||||
algoliaOptions: {
|
||||
hitsPerPage: 5,
|
||||
algolia: fbContent({
|
||||
internal: undefined,
|
||||
external: {
|
||||
apiKey: '2df980e7ffc95c19552790f7cad32666',
|
||||
indexName: 'fbflipper',
|
||||
algoliaOptions: {
|
||||
hitsPerPage: 5,
|
||||
},
|
||||
},
|
||||
}),
|
||||
prism: {
|
||||
@@ -166,8 +168,4 @@ const siteConfig = {
|
||||
],
|
||||
};
|
||||
|
||||
function FBInternalOnly(elements, fallback) {
|
||||
return process.env.FB_INTERNAL == 1 ? elements : fallback || [];
|
||||
}
|
||||
|
||||
module.exports = siteConfig;
|
||||
|
||||
Reference in New Issue
Block a user