This repository has been archived by the owner on Oct 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4dd97f
commit 35624ce
Showing
3 changed files
with
151 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
require('dotenv').config({ | ||
path: '.env', | ||
}); | ||
require("dotenv").config({ | ||
path: ".env", | ||
}) | ||
|
||
const AWS = require('aws-sdk'); | ||
const AWS = require("aws-sdk") | ||
|
||
AWS.config.update({ | ||
accessKeyId: process.env.AWS_ACCESS_KEY_ID, | ||
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, | ||
}); | ||
}) | ||
|
||
const getValidFiles = function(metadata) { | ||
file_keys = ['File_1', 'File_2', 'File_3', 'File_4', 'File_5'] | ||
return file_keys.map(key =>{ | ||
if (metadata[key] != "" && metadata[key].endsWith('.mp3')) { | ||
file_keys = ["File_1", "File_2", "File_3", "File_4", "File_5"] | ||
return file_keys.map(key => { | ||
if (metadata[key] != "" && metadata[key].endsWith(".mp3")) { | ||
return metadata[key] | ||
}} | ||
) | ||
} | ||
}) | ||
} | ||
|
||
module.exports = { | ||
|
@@ -25,78 +25,156 @@ module.exports = { | |
author: `The C3 Church`, | ||
}, | ||
plugins: [ | ||
{ | ||
resolve:`gatsby-transformer-json`, | ||
options: { | ||
typeName: ({ node, object, isArray }) => { | ||
return node.extension | ||
}, | ||
} | ||
{ | ||
resolve: `gatsby-transformer-json`, | ||
options: { | ||
typeName: ({ node, object, isArray }) => { | ||
return node.extension | ||
}, | ||
}, | ||
{ | ||
}, | ||
{ | ||
resolve: `gatsby-source-filesystem`, | ||
options: { | ||
name: `metadata`, | ||
path: `${__dirname}/data/`, | ||
}, | ||
}, | ||
{ | ||
resolve: 'gatsby-source-s3', | ||
options: { | ||
aws: { | ||
accessKeyId: process.env.AWS_ACCESS_KEY, | ||
secretAccessKey: process.env.AWS_SECRET_ACCESS, | ||
}, | ||
buckets: ['thec3-teaching-series'], | ||
{ | ||
resolve: `gatsby-source-filesystem`, | ||
options: { | ||
name: `images`, | ||
path: `${__dirname}/src/images`, | ||
}, | ||
}, | ||
{ | ||
resolve: "gatsby-source-s3", | ||
options: { | ||
aws: { | ||
accessKeyId: process.env.AWS_ACCESS_KEY, | ||
secretAccessKey: process.env.AWS_SECRET_ACCESS, | ||
}, | ||
buckets: ["thec3-teaching-series"], | ||
}, | ||
{ | ||
resolve: `gatsby-plugin-feed`, | ||
options: { | ||
query: `{ | ||
}, | ||
{ | ||
resolve: `gatsby-plugin-feed`, | ||
options: { | ||
query: `{ | ||
site { | ||
siteMetadata { | ||
title | ||
author | ||
description | ||
} | ||
} | ||
imageSharp { | ||
original { | ||
src | ||
} | ||
} | ||
}`, | ||
feeds: [ | ||
setup: ({ query, ...rest }) => ({ | ||
custom_namespaces: { | ||
itunes: "http://www.itunes.com/dtds/podcast-1.0.dtd", | ||
}, | ||
custom_elements: [ | ||
{ "itunes:author": "The C3 Church" }, | ||
{ "itunes:explicit": "No" }, | ||
{ | ||
serialize: ({ query: { site, allS3Object, allJson } }) => { | ||
return allJson.edges.map(({node}) => { | ||
S3Obj = allS3Object.edges.filter((s3node) => { | ||
var s3node = s3node.node | ||
// get a list of files from the JSON blob | ||
validMediaFiles = getValidFiles(node) | ||
// | ||
var thing = validMediaFiles.filter(file => | ||
s3node.Key.endsWith(file) | ||
) | ||
return thing[0] | ||
})[0] | ||
if (S3Obj !== undefined) { | ||
var S3ObjNode = S3Obj.node | ||
var s3URL = `https://${S3ObjNode.Name}.s3.amazonaws.com/${S3ObjNode.Key}` | ||
var description = node.Description | ||
if (node.Speaker != '') { | ||
description = description + `, Speaker: ${node.Speaker}` | ||
} | ||
if (node.Bible_References != '') { | ||
description = description + `, Bible Reference: ${node.Bible_References}` | ||
} | ||
return { | ||
title: node.Recording_Title, | ||
description: description, | ||
date: new Date(S3ObjNode.Key.split('/').splice(0,3).join('-')), | ||
"itunes:summary": `Welcome to the audio podcast feed of The C3 Church. To find out more visit http://www.thec3.uk`, | ||
}, | ||
{ | ||
"itunes:category": [ | ||
{ | ||
_attr: { | ||
text: "Religion & Spirituality", | ||
}, | ||
}, | ||
{ | ||
"itunes:category": { | ||
_attr: { | ||
text: "Christianity", | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
{ | ||
"itunes:image": { | ||
_attr: { | ||
href: query.imageSharp.original.src, | ||
}, | ||
}, | ||
}, | ||
{ | ||
"itunes:owner": [ | ||
{ "itunes:name": "The C3 Church" }, | ||
{ "itunes:email": "[email protected]" }, | ||
], | ||
}, | ||
], | ||
...rest | ||
} ), | ||
feeds: [ | ||
{ | ||
serialize: ({ | ||
query: { site, imageSharp, allS3Object, allJson }, | ||
}) => { | ||
return allJson.edges.map(({ node }) => { | ||
S3Obj = allS3Object.edges.filter(s3node => { | ||
var s3node = s3node.node | ||
// get a list of files from the JSON blob | ||
validMediaFiles = getValidFiles(node) | ||
// | ||
var thing = validMediaFiles.filter(file => | ||
s3node.Key.endsWith(file) | ||
) | ||
return thing[0] | ||
})[0] | ||
if (S3Obj !== undefined) { | ||
var S3ObjNode = S3Obj.node | ||
var s3URL = `https://${S3ObjNode.Name}.s3.amazonaws.com/${S3ObjNode.Key}` | ||
var description = node.Description | ||
if (node.Speaker != "") { | ||
description = description + `, Speaker: ${node.Speaker}` | ||
} | ||
if (node.Bible_References != "") { | ||
description = | ||
description + | ||
`, Bible Reference: ${node.Bible_References}` | ||
} | ||
return { | ||
title: node.Recording_Title, | ||
description: description, | ||
date: new Date( | ||
S3ObjNode.Key.split("/") | ||
.splice(0, 3) | ||
.join("-") | ||
), | ||
url: s3URL, | ||
guid: s3URL, | ||
author: node.Speaker, | ||
enclosure: { | ||
url: s3URL, | ||
guid: s3URL, | ||
} | ||
size: S3ObjNode.Size, | ||
type: "audio/mpeg", | ||
}, | ||
custom_elements: [ | ||
{ "itunes:author": node.Speaker }, | ||
{ | ||
"itunes:image": { | ||
_attr: { | ||
href: imageSharp.original.src, | ||
}, | ||
}, | ||
}, | ||
], | ||
} | ||
}) | ||
}, | ||
query: ` | ||
} | ||
}) | ||
}, | ||
query: ` | ||
{ | ||
allS3Object(filter: {Key: {regex: "/[mp3]$/"}}) { | ||
edges { | ||
|
@@ -123,15 +201,20 @@ module.exports = { | |
File_5 | ||
} | ||
} | ||
} | ||
imageSharp { | ||
original { | ||
src | ||
} | ||
} | ||
} | ||
`, | ||
output: "/feed.xml", | ||
title: "The C3 Audio Podcast", | ||
}, | ||
], | ||
}, | ||
output: "/feed.xml", | ||
title: "The C3 Audio Podcast", | ||
}, | ||
], | ||
}, | ||
}, | ||
`gatsby-plugin-react-helmet`, | ||
`gatsby-transformer-sharp`, | ||
`gatsby-plugin-sharp`, | ||
|
@@ -144,7 +227,7 @@ module.exports = { | |
background_color: `#663399`, | ||
theme_color: `#663399`, | ||
display: `minimal-ui`, | ||
icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site. | ||
icon: `src/images/avatars-500x500.jpg`, // This path is relative to the root of the site. | ||
}, | ||
}, | ||
// this (optional) plugin enables Progressive Web App + Offline functionality | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.