Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Commit

Permalink
feat: ✨ publish RSS feed
Browse files Browse the repository at this point in the history
  • Loading branch information
filipowm committed Jun 5, 2020
1 parent de9364e commit a1a23b9
Show file tree
Hide file tree
Showing 6 changed files with 303 additions and 158 deletions.
118 changes: 16 additions & 102 deletions config/config-reader.js
Original file line number Diff line number Diff line change
@@ -1,98 +1,7 @@
const fs = require('fs');
const _ = require('lodash');
const yaml = require('js-yaml');

const defaults = {
metadata: {
name: 'Gitbook Starter',
short_name: '',
description: '',
url: 'http://localhost',
pathPrefix: '/',
gaTrackingId: null,
ogImage: null,
docsLocation: 'https://github.com/filipowm/gatsby-gitbook-starter',
docsLocationType: 'github',
favicon: '/assets/favicon.png',
themeColor: '#',
},
header: {
logo: '',
logoLink: '/',
helpUrl: 'asdg',
links: [],
},
search: {
enabled: true,
indexName: 'docs',
algoliaAppId: null,
algoliaSearchKey: null,
algoliaAdminKey: null,
},
sidebar: {
enabled: true,
forcedNavOrder: [],
expanded: [],
groups: [],
links: [],
ignoreIndex: true,
poweredBy: {},
},

pwa: {
enabled: true, // disabling this will also remove the existing service worker.
manifest: {
name: 'Gitbook',
short_name: 'GitbookStarter',
start_url: '/',
background_color: '#6b37bf',
theme_color: '#6b37bf',
display: 'standalone',
crossOrigin: 'use-credentials',
icons: [
{
src: 'src/pwa-512.png',
sizes: `512x512`,
type: `image/png`,
},
],
},
},
features: {
search: {
enabled: true,
indexName: 'docs',
algoliaAppId: null,
algoliaSearchKey: null,
algoliaAdminKey: null,
},
toc: {
depth: 3,
},
previousNext: {
enabled: true,
arrowKeyNavigation: true
},
scrollTop: true,
showMetadata: true,
propagateNetlifyEnv: true,
pageProgress: {
enabled: false,
// includePaths: [],
excludePaths: ["/"],
height: 3,
prependToBody: false,
color: '#A05EB5'
},
mermaid: {
language: 'mermaid',
theme: 'dark', // default, dark, forest, neutral
options: {}, // https://mermaidjs.github.io/#/mermaidAPI
width: 300,
height: 300
}
},
};
const defaults = require('./default');

const readEnvOrDefault = (name, def) => {
let value = process.env[name];
Expand Down Expand Up @@ -196,25 +105,30 @@ class EnvReader extends ConfigReader {
}

class NetlifyEnvReader extends ConfigReader {

constructor(allowNetlifyEnvPropagation) {
super();
this.allowNetlifyEnvPropagation = allowNetlifyEnvPropagation;
}

read() {
if (this.allowNetlifyEnvPropagation && readEnvOrDefault("NETLIFY", false)) {
const context = readEnvOrDefault("CONTEXT");
const repositoryUrl = readEnvOrDefault("REPOSITORY_URL");
const url = readEnvOrDefault("URL");
const deployUrl = context === "production" ? url : readEnvOrDefault("DEPLOY_PRIME_URL", url);
console.log("Setting up Netlify variables.", "URL:", deployUrl, "Docs Location:", repositoryUrl)
if (this.allowNetlifyEnvPropagation && readEnvOrDefault('NETLIFY', false)) {
const context = readEnvOrDefault('CONTEXT');
const repositoryUrl = readEnvOrDefault('REPOSITORY_URL');
const url = readEnvOrDefault('URL');
const deployUrl = context === 'production' ? url : readEnvOrDefault('DEPLOY_PRIME_URL', url);
console.log(
'Setting up Netlify variables.',
'URL:',
deployUrl,
'Docs Location:',
repositoryUrl
);
return {
metadata: {
url: deployUrl,
docsLocation: repositoryUrl,
}
}
},
};
}
return {};
}
Expand All @@ -228,7 +142,7 @@ const read = () => {
let config = _.merge(def, fileConfig);
config = _.merge(config, envConfig);
const netlifyConfig = new NetlifyEnvReader(config.features.propagateNetlifyEnv).read();
config = _.merge(config, netlifyConfig)
config = _.merge(config, netlifyConfig);
postProcessConfig(config);
return config;
};
Expand Down
91 changes: 52 additions & 39 deletions config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,54 @@
metadata:
name: GitBook Starter
short_name: GitBook
description:
description: Example Gitbook
language: en
pathPrefix: "/"
ogImage:
ogImage:
docsLocation: https://github.com/filipowm/gatsby-gitbook-starter
docsLocationType: github
editable: true
favicon: "/assets/favicon.png"
themeColor: "#ff0000"
header:
enabled: true
logo: ''
logo: ""
logoLink: "/"
helpUrl: ''
helpUrl: ""
links:
- text: GitBook
link: https://github.com/filipowm/gatsby-gitbook-starter
external: true
- text: Gatsby
link: https://www.gatsbyjs.org
external: true
- text: Docs
link: "/"
external: false
- text: GitBook
link: https://github.com/filipowm/gatsby-gitbook-starter
external: true
- text: Gatsby
link: https://www.gatsbyjs.org
external: true
- text: Docs
link: "/"
external: false
sidebar:
enabled: true
forcedNavOrder:
- "/introduction"
- "/configuration/basic"
- "/configuration/advanced"
expanded:
- "/introduction"
- "/configuration/basic"
- "/configuration/advanced"
expanded:
groups:
- order: 1
path: "/configuration"
icon: "/assets/settings.svg"
title: Configuration
- order: 2
path: "/syntax"
icon: "/assets/code.svg"
title: Syntax
- order: 3
path: "/developing"
title: Lol
- order: 1
path: "/configuration"
icon: "/assets/settings.svg"
title: Configuration
- order: 2
path: "/syntax"
icon: "/assets/code.svg"
title: Syntax
- order: 3
path: "/developing"
title: Lol
links:
- text: Gitbook
link: https://github.com/filipowm/gatsby-gitbook-starter
- text: React
link: https://reactjs.org
- text: Gitbook
link: https://github.com/filipowm/gatsby-gitbook-starter
- text: React
link: https://reactjs.org
ignoreIndex: true
poweredBy:
trademark: "/assets/gatsby.png"
Expand All @@ -60,9 +61,9 @@ pwa:
display: standalone
crossOrigin: use-credentials
icons:
- src: src/pwa-512.png
sizes: 512x512
type: image/png
- src: src/pwa-512.png
sizes: 512x512
type: image/png
features:
search:
enabled: true
Expand All @@ -76,17 +77,29 @@ features:
propagateNetlifyEnv: true
pageProgress:
enabled: true
includePaths:
includePaths:
- "/configuration/advanced/theme"
- regex: "^/syntax"
excludePaths:
- "/"
height: 3
prependToBody: false
color: '#A05EB5'
color: "#A05EB5"
mermaid:
language: 'mermaid'
theme: 'dark'
language: "mermaid"
theme: "dark"
options:
width: 300
height: 300
rss:
enabled: true
copyright: "2020, Mateusz Filipowicz"
webMaster: "Mateusz Filipowicz"
managingEditor: "Mateusz Filipowicz"
categories:
- Category 1
- Category 2
ttl: 60
matchRegex: "^/"
outputPath: "/rss.xml"
generator: "gidocs"
103 changes: 103 additions & 0 deletions config/default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
module.exports = {
metadata: {
name: 'Gitbook Starter',
short_name: '',
description: '',
language: 'en',
url: 'http://localhost',
pathPrefix: '/',
gaTrackingId: null,
ogImage: null,
docsLocation: 'https://github.com/filipowm/gatsby-gitbook-starter',
docsLocationType: 'github',
favicon: '/assets/favicon.png',
themeColor: '#',
},
header: {
logo: '',
logoLink: '/',
helpUrl: '',
links: [],
},
search: {
enabled: false,
indexName: 'docs',
algoliaAppId: null,
algoliaSearchKey: null,
algoliaAdminKey: null,
},
sidebar: {
enabled: true,
ignoreIndex: true,
forcedNavOrder: [],
expanded: [],
groups: [],
links: [],
poweredBy: {},
},

pwa: {
enabled: true, // disabling this will also remove the existing service worker.
manifest: {
name: 'Gitbook',
short_name: 'GitbookStarter',
start_url: '/',
background_color: '#6b37bf',
theme_color: '#6b37bf',
display: 'standalone',
crossOrigin: 'use-credentials',
icons: [
{
src: 'src/pwa-512.png',
sizes: `512x512`,
type: `image/png`,
},
],
},
},
features: {
search: {
enabled: true,
indexName: 'docs',
algoliaAppId: null,
algoliaSearchKey: null,
algoliaAdminKey: null,
},
toc: {
depth: 3,
},
previousNext: {
enabled: true,
arrowKeyNavigation: true,
},
scrollTop: true,
showMetadata: true,
propagateNetlifyEnv: true,
pageProgress: {
enabled: false,
// includePaths: [],
excludePaths: ['/'],
height: 3,
prependToBody: false,
color: '#A05EB5',
},
mermaid: {
language: 'mermaid',
theme: 'dark', // default, dark, forest, neutral
options: {}, // https://mermaidjs.github.io/#/mermaidAPI
width: 300,
height: 300,
},
rss: {
enabled: true,
copyright: '2020, Mateusz Filipowicz',
webMaster: 'Mateusz Filipowicz (matfilipowicz@gmail.com)',
managingEditor: 'Mateusz Filipowicz (matfilipowicz@gmail.com)',
categories: ['GatsbyJS', 'Docs'],
ttl: '60',
matchRegex: '^/',
outputPath: '/rss.xml',
generator: 'gidocs',
},
},
};

0 comments on commit a1a23b9

Please sign in to comment.