Skip to content

Commit

Permalink
Add Related Docs Support
Browse files Browse the repository at this point in the history
  • Loading branch information
rwinch committed Oct 10, 2023
1 parent f434520 commit 34bfa04
Show file tree
Hide file tree
Showing 10 changed files with 316 additions and 46 deletions.
2 changes: 2 additions & 0 deletions preview-src/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Author Name
:page-pagination:
:chomp-package-replacement: com.acme
:tabs-sync-option:
:page-related-doc-categories: security
:page-related-doc-projects: framework

image:multirepo-ssg.svg[Multirepo SSG,200,float=right]
Platonem complectitur mediocritatem ea eos.
Expand Down
4 changes: 4 additions & 0 deletions preview-src/spring-projects.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
= Spring Projects
:page-article: spring-projects

This won't be displayed because we override the article
21 changes: 21 additions & 0 deletions preview-src/spring-projects.adoc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
url: /all-docs.html
component:
name: security
version: '6.1.0'
latest:
url: '/index.html'
previous:
content: Quickstart
url: '#'
urlType: 'internal'
next:
content: Liber Recusabo
url: '#'
urlType: 'internal'
breadcrumbs:
- content: Spring Security
url: '#'
urlType: fragment
- content: Overview
url: '#'
urlType: fragment
251 changes: 251 additions & 0 deletions src/helpers/related_projects.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
'use strict'

module.exports = (categories, projectIds) => relatedProjects(categories, projectIds)

function relatedProjects (categories = [], projectIds = []) {
const projectDocumentation = [
{
href: 'https://docs.spring.io/spring-framework/reference/',
id: 'framework',
text: 'Spring Framework',
categories: ['core'],
},
{
text: 'Spring Cloud',
id: 'cloud',
categories: ['cloud'],
children: [
{
href: 'https://docs.spring.io/spring-cloud-build/reference/',
id: 'cloud-build',
text: 'Spring Cloud Build',
categories: ['cloud'],
},
{
href: 'https://docs.spring.io/spring-cloud-bus/reference/',
id: 'cloud-bus',
text: 'Spring Cloud Bus',
categories: ['cloud'],
},
{
href: 'https://docs.spring.io/spring-cloud-circuitbreaker/reference/',
id: 'cloud-circuitbreaker',
text: 'Spring Cloud Circuit Breaker',
categories: ['cloud'],
},
{
href: 'https://docs.spring.io/spring-cloud-commons/reference/',
id: 'cloud-commons',
text: 'Spring Cloud Commons',
categories: ['cloud'],
},
{
href: 'https://docs.spring.io/spring-cloud-config/reference/',
id: 'cloud-config',
text: 'Spring Cloud Config',
categories: ['cloud'],
},
{
href: 'https://docs.spring.io/spring-cloud-consul/reference/',
id: 'cloud-consul',
text: 'Spring Cloud Consul',
categories: ['cloud'],
},
{
href: 'https://docs.spring.io/spring-cloud-contract/reference/',
id: 'cloud-contract',
text: 'Spring Cloud Contract',
categories: ['cloud'],
},
{
href: 'https://docs.spring.io/spring-cloud-function/reference/',
id: 'cloud-function',
text: 'Spring Cloud Function',
categories: ['cloud'],
},
{
href: 'https://docs.spring.io/spring-cloud-gateway/reference/',
id: 'cloud-gateway',
text: 'Spring Cloud Gateway',
categories: ['cloud'],
},
{
href: 'https://docs.spring.io/spring-cloud-kubernetes/reference/',
id: 'cloud-kubernetes',
text: 'Spring Cloud Kubernetes',
categories: ['cloud'],
},
{
href: 'https://docs.spring.io/spring-cloud-netflix/reference/',
id: 'cloud-netflix',
text: 'Spring Cloud Netflix',
categories: ['cloud'],
},
{
href: 'https://docs.spring.io/spring-cloud-openfeign/reference/',
id: 'cloud-openfeign',
text: 'Spring Cloud OpenFeign',
categories: ['cloud'],
},
{
href: 'https://docs.spring.io/spring-cloud-stream/reference/',
id: 'cloud-stream',
text: 'Spring Cloud Stream',
categories: ['cloud'],
},
{
href: 'https://docs.spring.io/spring-cloud-task/reference/',
id: 'cloud-task',
text: 'Spring Cloud Task',
categories: ['cloud'],
},
{
href: 'https://docs.spring.io/spring-cloud-vault/reference/',
id: 'cloud-vault',
text: 'Spring Cloud Vault',
categories: ['cloud'],
},
{
href: 'https://docs.spring.io/spring-cloud-zookeeper/reference/',
id: 'cloud-zookeeper',
text: 'Spring Cloud Zookeeper',
categories: ['cloud'],
},
],
},
{
text: 'Spring Data',
id: 'data',
categories: ['data'],
children: [
{
href: 'https://docs.spring.io/spring-data/cassandra/reference/',
id: 'data/cassandra',
text: 'Spring Data Cassandra',
categories: ['data'],
},
{
href: 'https://docs.spring.io/spring-data/commons/reference/',
id: 'data/commons',
text: 'Spring Data Commons',
categories: ['data'],
},
{
href: 'https://docs.spring.io/spring-data/couchbase/reference/',
id: 'data/couchbase',
text: 'Spring Data Couchbase',
categories: ['data'],
},
{
href: 'https://docs.spring.io/spring-data/elasticsearch/reference/',
id: 'data/elasticsearch',
text: 'Spring Data Elasticsearch',
categories: ['data'],
},
{
href: 'https://docs.spring.io/spring-data/jpa/reference/',
id: 'data/jpa',
text: 'Spring Data JPA',
categories: ['data'],
},
{
href: 'https://docs.spring.io/spring-data/keyvalue/reference/',
id: 'data/keyvalue',
text: 'Spring Data KeyValue',
categories: ['data'],
},
{
href: 'https://docs.spring.io/spring-data/ldap/reference/',
id: 'data/ldap',
text: 'Spring Data LDAP',
categories: ['data'],
},
{
href: 'https://docs.spring.io/spring-data/mongodb/reference/',
id: 'data/mongodb',
text: 'Spring Data MongoDB',
categories: ['data'],
},
{
href: 'https://docs.spring.io/spring-data/redis/reference/',
id: 'data/redis',
text: 'Spring Data Redis',
categories: ['data'],
},
{
href: 'https://docs.spring.io/spring-data/relational/reference/',
id: 'data/relational',
text: 'Spring Data JDBC & R2DBC',
categories: ['data'],
},
{
href: 'https://docs.spring.io/spring-data/rest/reference/',
id: 'data/rest',
text: 'Spring Data REST',
categories: ['data'],
},
],
},
{ href: 'https://docs.spring.io/spring-integration/reference/', id: 'integration', text: 'Spring Integration' },
{ href: 'https://docs.spring.io/spring-batch/reference/', id: 'batch', text: 'Spring Batch' },
{
href: 'https://docs.spring.io/spring-security/reference/',
id: 'security',
text: 'Spring Security',
categories: ['security', 'core'],
children: [
{
href: 'https://docs.spring.io/spring-authorization-server/reference/',
id: 'authorization-server',
text: 'Spring Authorization Server',
categories: ['security'],
},
{
href: 'https://docs.spring.io/spring-ldap/reference/',
id: 'ldap',
text: 'Spring LDAP',
categories: ['security'],
},
{
href: 'https://docs.spring.io/spring-security-kerberos/reference/',
id: 'security-kerberos',
text: 'Spring Security Kerberos',
categories: ['security'],
},
{
href: 'https://docs.spring.io/spring-session/reference/',
id: 'session',
text: 'Spring Session',
categories: ['security'],
},
{
href: 'https://docs.spring.io/spring-vault/reference/',
id: 'vault',
text: 'Spring Vault',
categories: ['security'],
},
],
},
{ href: 'https://docs.spring.io/spring-ai/reference/', id: 'ai', text: 'Spring AI' },
{ href: 'https://docs.spring.io/spring-cli/reference/', id: 'cli', text: 'Spring CLI' },
{ href: 'https://docs.spring.io/spring-graphql/reference/', id: 'graphql', text: 'Spring GraphQL' },
{ href: 'https://docs.spring.io/spring-kafka/reference/', id: 'kafka', text: 'Spring for Apache Kafka' },
{ href: 'https://docs.spring.io/spring-modulith/reference/', id: 'modulith', text: 'Spring Modulith' },
{ href: 'https://docs.spring.io/spring-pulsar/reference/', id: 'pulsar', text: 'Spring Pulsar' },
{ href: 'https://docs.spring.io/spring-shell/reference/', id: 'shell', text: 'Spring Shell' },
]
return projectDocumentation.filter(
(p) => filterProjectByCategories(p, categories) || filterProjectByProjectIds(p, projectIds)
)
}

function filterProjectByCategories (project, categories) {
return (
categories.length === 0 ||
categories.some((category) => project.categories && project.categories.includes(category))
)
}

function filterProjectByProjectIds (project, projectIds) {
return projectIds.length === 0 || projectIds.some((projectId) => project.id === projectId)
}
3 changes: 3 additions & 0 deletions src/helpers/split.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict'

module.exports = (s) => (s ? s.split(',') : [])
9 changes: 9 additions & 0 deletions src/partials/article-spring-projects.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="page-search">
<div class="search-wrap">
<h1 id="page-title" class="page">Spring Projects</h1>
<ul class="projects-list">
{{#each (related_projects [''] [''])}}
{{> related-project this}}
{{/each}}
</ul>
</div>
2 changes: 2 additions & 0 deletions src/partials/main.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
{{> article-404}}
{{else if (eq page.attributes.article 'search')}}
{{> article-search}}
{{else if (eq page.attributes.article 'spring-projects')}}
{{> article-spring-projects}}
{{else}}
{{> toc}}
{{> article}}
Expand Down
12 changes: 12 additions & 0 deletions src/partials/related-project.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{#if ./href}}
<li><a href="{{./href}}">{{./text}}</a></li>
{{else}}
<li>{{./text}}</li>
{{/if}}
{{#if ./children}}
<ul>
{{#each ./children}}
{{> related-project this}}
{{/each}}
</ul>
{{/if}}
11 changes: 11 additions & 0 deletions src/partials/related-projects.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<ul class="projects">
<li>
Related Spring Documentation
<ul class="projects-list">
{{#each (related_projects (split page.attributes.related-doc-categories) (split page.attributes.related-doc-projects))}}
{{> related-project this}}
{{/each}}
</ul>
</li
<li><a href="{{{relativize './spring-projects.html'}}}">All Docs...</a></li>
</ul>
47 changes: 1 addition & 46 deletions src/partials/version.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -28,52 +28,7 @@
</ul>
</div>
<div class="col-right">
<ul class="projects">
<li>
Related Spring Documentation
<ul class="projects-list">
<li><a href="https://docs.spring.io/spring-framework/reference/">Spring Framework</a></li>
<li>
Spring Cloud
<ul>
<li><a href="https://docs.spring.io/spring-cloud-commons/reference/spring-cloud-commons/">Spring Cloud Commons</a></li>
</ul>
</li>
<li>
Spring Data
<ul>
<li><a href="https://docs.spring.io/spring-data/commons/reference/">Spring Data Commons</a></li>
<li><a href="https://docs.spring.io/spring-data/jpa/reference/">Spring Data JPA</a></li>
<li><a href="https://docs.spring.io/spring-data/ldap/reference/">Spring Data LDAP</a></li>
<li><a href="https://docs.spring.io/spring-data/redis/reference/">Spring Data Redis</a></li>
<li><a href="https://docs.spring.io/spring-data/mongodb/reference/">Spring Data MongoDB</a></li>
<li><a href="https://docs.spring.io/spring-data/relational/reference/">Spring Data JDBC & R2DBC</a></li>
<li><a href="https://docs.spring.io/spring-data/rest/reference/">Spring Data REST</a></li>
<li><a href="https://docs.spring.io/spring-data/cassandra/reference/">Spring Data Cassandra</a></li>
<li><a href="https://docs.spring.io/spring-data/couchbase/reference/">Spring Data Couchbase</a></li>
<li><a href="https://docs.spring.io/spring-data/elasticsearch/reference/">Spring Data Elasticsearch</a></li>
</ul>
</li>
<li><a href="https://docs.spring.io/spring-integration/reference/">Spring Integration</a></li>
<li><a href="https://docs.spring.io/spring-batch/reference/">Spring Batch</a></li>
<li>
<a href="https://docs.spring.io/spring-security/reference/">Spring Security</a>
<ul>
<li><a href="https://docs.spring.io/spring-ldap/reference/">Spring LDAP</a></li>
<li><a href="https://docs.spring.io/spring-session/reference/">Spring Session</a></li>
<li><a href="https://docs.spring.io/spring-authorization-server/reference/">Spring Authorization Server</a></li>
<li><a href="https://docs.spring.io/spring-vault/reference/">Spring Vault</a></li>
<li><a href="https://docs.spring.io/spring-security-kerberos/reference/">Spring Security Kerberos</a></li>
</ul>
</li>
<li><a href="https://docs.spring.io/spring-ai/reference/">Spring AI</a></li>
<li><a href="https://docs.spring.io/spring-cli/reference/">Spring CLI</a></li>
<li><a href="https://docs.spring.io/spring-graphql/reference/">Spring GraphQL</a></li>
<li><a href="https://docs.spring.io/spring-kafka/reference/">Spring for Apache Kafka</a></li>
<li><a href="https://docs.spring.io/spring-shell/reference/">Spring Shell</a></li>
</ul>
</li>
</ul>
{{> related-projects}}
</div>
</div>
</main>
Expand Down

0 comments on commit 34bfa04

Please sign in to comment.