Skip to content

Commit

Permalink
Removed the need for original Simply theme to be installed
Browse files Browse the repository at this point in the history
  • Loading branch information
anarion80 committed Nov 10, 2021
1 parent b8e8d98 commit 804f481
Show file tree
Hide file tree
Showing 50 changed files with 22,191 additions and 118 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Rewritten from Handlebars theme to React/Gatsby.
- [Social accounts link](https://godofredo.ninja/ghost-theme/simply/settings/#socialmedia)
- [PrismJS syntax highlighting](https://prismjs.com/index.html#supported-languages) - basic only
- Different Home Page variants and Post formats
- Post Format
- Post Format (:warning: use internal tags and not `custom_template` field!)
- [Post Default](https://godofredo.ninja/ghost-theme/simply/post-format/#post-default)
- [Post Full](https://godofredo.ninja/ghost-theme/simply/post-format/#post-full)
- [Post Wide](https://godofredo.ninja/ghost-theme/simply/post-format/#post-wide)
Expand All @@ -32,15 +32,15 @@ Rewritten from Handlebars theme to React/Gatsby.
- Footer Default
- Footer Dark
- Footer Not Menu Secondary
- Archive
- Archive (:warning: use internal tags and not `custom_template` field!)
- [Authors Page](https://godofredo.ninja/ghost-theme/simply/authors-and-tags-page/#authors-page)
- [Tags Page](https://godofredo.ninja/ghost-theme/simply/authors-and-tags-page/#tags-page)
- Page
- [Contact](https://godofredo.ninja/ghost-theme/simply/contact-page/)
- [Kusi Doc](https://godofredo.ninja/ghost-theme/simply/kusi-doc/) for the documentation of your project
- [Contact](https://godofredo.ninja/ghost-theme/simply/contact-page/) (:warning: use internal tags and not `custom_template` field!)
- [Kusi Doc](https://godofredo.ninja/ghost-theme/simply/kusi-doc/) for the documentation of your project (:warning: use internal tags and not `custom_template` field!)
- 404
- [Podcasts Page](https://godofredo.ninja/ghost-theme/simply/podcasts-page/)
- [Portfolio Page](https://godofredo.ninja/ghost-theme/simply/portfolio-page/)
- [Podcasts Page](https://godofredo.ninja/ghost-theme/simply/podcasts-page/) (:warning: no need to create the page, just use internal tags on the post)
- [Portfolio Page](https://godofredo.ninja/ghost-theme/simply/portfolio-page/) (:warning: no need to create the page, just use internal tags on the post)
- Support for [different Languages](https://godofredo.ninja/ghost-theme/simply/languages)
- Related Articles
- Social share buttons support for posts
Expand Down Expand Up @@ -92,7 +92,7 @@ yarn

# 🏃‍♂️ Running

Start the development server. You now have a Gatsby site pulling content from headless Ghost. Please ensure you have the [Simply Ghost Theme](https://github.com/godofredoninja/simply) installed in your Ghost instance, including all the Routes if you want to use all the features.
Start the development server. You now have a Gatsby site pulling content from headless Ghost. You do not need to have original [Simply Ghost Theme](https://github.com/godofredoninja/simply) installed in your Ghost instance, nor have any additional Routes set up there.

```bash
gatsby develop
Expand Down Expand Up @@ -158,6 +158,8 @@ Finally, configure your desired URL in `siteConfig.js`, so links (e. g. canonica
}
```

To use custom post templates, add a particular internal tag to the post (i.e. `#custom-post-wide`, `#custom-kusi-doc`, etc).

Demo and the repo is the "maximum version" with all possible types of Home Page variants, Post Templates, Portfolio, Docs, etc. Adjust/remove as needed.

 
Expand Down
84 changes: 64 additions & 20 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,14 @@ exports.createPages = async ({ graphql, actions }) => {
const result = await graphql(`
{
blogPosts: allGhostPost(sort: { order: ASC, fields: published_at }
filter: {tags: {elemMatch: {name: {nin: ["#podcast","#portfolio","#kusi-doc"]}}}}) {
filter: {tags: {elemMatch: {name: {nin: ["#podcast","#portfolio","#custom-kusi-doc"]}}}}) {
edges {
node {
slug
custom_template
tags {
name
slug
}
primary_tag {
slug
}
Expand All @@ -141,7 +144,10 @@ exports.createPages = async ({ graphql, actions }) => {
edges {
node {
slug
custom_template
tags {
name
slug
}
primary_tag {
slug
}
Expand All @@ -159,7 +165,10 @@ exports.createPages = async ({ graphql, actions }) => {
edges {
node {
slug
custom_template
tags {
name
slug
}
primary_tag {
slug
}
Expand All @@ -171,11 +180,14 @@ exports.createPages = async ({ graphql, actions }) => {
}
}
docPosts: allGhostPost(sort: { order: ASC, fields: published_at }
filter: {tags: {elemMatch: {name: {in: ["#kusi-doc"]}}}}) {
filter: {tags: {elemMatch: {name: {in: ["#custom-kusi-doc"]}}}}) {
edges {
node {
slug
custom_template
tags {
name
slug
}
primary_tag {
slug
}
Expand Down Expand Up @@ -209,7 +221,10 @@ exports.createPages = async ({ graphql, actions }) => {
node {
slug
url
custom_template
tags {
name
slug
}
internal {
type
}
Expand Down Expand Up @@ -256,6 +271,7 @@ exports.createPages = async ({ graphql, actions }) => {
const authorTemplate = path.resolve(`./src/templates/author.js`)
const podcastTemplate = path.resolve(`./src/templates/podcast.js`)
const portfolioTemplate = path.resolve(`./src/templates/portfolio.js`)
const docsTemplate = path.resolve(`./src/templates/docs.js`)

// Create tag pages
tags.forEach(({ node }) => {
Expand All @@ -276,6 +292,7 @@ exports.createPages = async ({ graphql, actions }) => {
pathPrefix: ({ pageNumber }) => ((pageNumber === 0) ? url : `${url}/page`),
context: {
slug: node.slug,
collectionPath: `/tag/`,
},
})
})
Expand All @@ -299,6 +316,7 @@ exports.createPages = async ({ graphql, actions }) => {
pathPrefix: ({ pageNumber }) => ((pageNumber === 0) ? url : `${url}/page`),
context: {
slug: node.slug,
collectionPath: `/author/`,
},
})
})
Expand All @@ -307,15 +325,16 @@ exports.createPages = async ({ graphql, actions }) => {
pages.forEach(({ node }) => {
// This part here defines, that our pages will use
// a `/:slug/` permalink.
node.url = `/${node.slug}/`
const url = `/${node.slug}/`

createPage({
path: node.url,
path: url,
component: getCustomTemplate(node),
context: {
// Data passed to context is available
// in page queries as GraphQL variables.
slug: node.slug,
collectionPath: `/`,
},
})
})
Expand All @@ -324,17 +343,18 @@ exports.createPages = async ({ graphql, actions }) => {
posts.forEach(({ node }, index) => {
// This part here defines, that our posts will use
// a `/:slug/` permalink.
node.url = `/${node.slug}/`
const url = `/${node.slug}/`
const prev = index === 0 ? null : posts[index - 1].node
const next = index === posts.length - 1 ? null : posts[index + 1].node

createPage({
path: node.url,
path: url,
component: getCustomTemplate(node),
context: {
// Data passed to context is available
// in page queries as GraphQL variables.
slug: node.slug,
collectionPath: `/`,
prev: prev ? prev.slug : null,
next: next ? next.slug : null,
primary_tag: node.primary_tag ? node.primary_tag.slug : null,
Expand All @@ -357,6 +377,7 @@ exports.createPages = async ({ graphql, actions }) => {
// Data passed to context is available
// in page queries as GraphQL variables.
slug: node.slug,
collectionPath: `/podcast`,
prev: prev ? prev.slug : null,
next: next ? next.slug : null,
primary_tag: node.primary_tag ? node.primary_tag.slug : null,
Expand All @@ -379,6 +400,7 @@ exports.createPages = async ({ graphql, actions }) => {
// Data passed to context is available
// in page queries as GraphQL variables.
slug: node.slug,
collectionPath: `/portfolio`,
prev: prev ? prev.slug : null,
next: next ? next.slug : null,
primary_tag: node.primary_tag ? node.primary_tag.slug : null,
Expand All @@ -401,17 +423,48 @@ exports.createPages = async ({ graphql, actions }) => {
// Data passed to context is available
// in page queries as GraphQL variables.
slug: node.slug,
collectionPath: `/docs`,
prev: prev ? prev.slug : null,
next: next ? next.slug : null,
primary_tag: node.primary_tag ? node.primary_tag.slug : null,
},
})
})

// Create podcasts page with pagination
paginate({
createPage,
items: podcastPosts,
itemsPerPage: postsPerPage,
component: podcastTemplate,
context: {
// Data passed to context is available
// in page queries as GraphQL variables.
collectionPath: `/podcast`,
},
pathPrefix: ({ pageNumber }) => ((pageNumber === 0) ? `/podcast` : `/podcast/page`),
})

// Create portfolio page
createPage({
path: `/portfolio`,
component: portfolioTemplate,
context: {
// Data passed to context is available
// in page queries as GraphQL variables.
collectionPath: `/portfolio`,
},
})

// Create docs page
createPage({
path: `/docs`,
component: docsTemplate,
context: {
// Data passed to context is available
// in page queries as GraphQL variables.
collectionPath: `/docs`,
},
})

// Create archive example page
Expand Down Expand Up @@ -580,15 +633,6 @@ exports.createPages = async ({ graphql, actions }) => {
component: path.resolve(`./src/templates/custom/index-personal.js`),
})

// Create podcast pagination
paginate({
createPage,
items: podcastPosts,
itemsPerPage: postsPerPage,
component: podcastTemplate,
pathPrefix: ({ pageNumber }) => ((pageNumber === 0) ? `/podcast` : `/podcast/page`),
})

// Create pagination
paginate({
createPage,
Expand Down
Loading

0 comments on commit 804f481

Please sign in to comment.