-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancement/issue 128 title from data #300
Changes from all commits
123333a
cd4fb7f
2541747
0ac54ab
ca50e62
9618d5f
08ba3b8
6c7b68b
2fccd6e
5c05f8d
260cdd5
ced3789
b021588
c318fae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,7 +72,7 @@ const createGraphFromPages = async (pagesDir, config) => { | |
label = label || generateLabelHash(filePath); | ||
|
||
// set <title></title> element text, override with markdown title | ||
title = title || config.title; | ||
title = title || ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
/* | ||
* Variable Definitions | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,9 @@ import { connectRouter } from 'lit-redux-router'; | |
import { applyMiddleware, createStore, compose as origCompose, combineReducers } from 'redux'; | ||
import { lazyReducerEnhancer } from 'pwa-helpers/lazy-reducer-enhancer.js'; | ||
import thunk from 'redux-thunk'; | ||
import client from '@greenwood/cli/data/client'; | ||
import ConfigQuery from '@greenwood/cli/data/queries/config'; | ||
import GraphQuery from '@greenwood/cli/data/queries/graph'; | ||
|
||
// eslint-disable-next-line no-underscore-dangle | ||
const compose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || origCompose; | ||
|
@@ -17,6 +20,37 @@ import './list'; | |
connectRouter(store); | ||
|
||
class AppComponent extends LitElement { | ||
|
||
async connectedCallback() { | ||
super.connectedCallback(); | ||
const route = window.location.pathname; | ||
const response = await Promise.all([ | ||
await client.query({ | ||
query: ConfigQuery | ||
}), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it easier to instead include this data as part of the graph, from within the graph lifecycle, then queried as part of the graph query? Just spitballing here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, two queries here isn't ideal, that said, I think However, it would be great if apollo-client could support sending multiple queries for us, then we wouldn't have to use |
||
await client.query({ | ||
query: GraphQuery | ||
}) | ||
]); | ||
const { config } = response[0].data; | ||
const currentPage = response[1].data.graph.filter((page) => { | ||
return route === page.link; | ||
})[0]; | ||
const currentPageTitleSuffix = currentPage.link === '/' | ||
? '' | ||
: ` - ${currentPage.title}`; | ||
const fullTitle = `${config.title}${currentPageTitleSuffix}`; | ||
|
||
this.setDocoumentTitle(fullTitle); | ||
} | ||
|
||
setDocoumentTitle(title) { | ||
const head = document.head; | ||
const titleElement = head.getElementsByTagName('title')[0]; | ||
|
||
titleElement.innerHTML = title; | ||
} | ||
|
||
render() { | ||
return html` | ||
MYROUTES | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍