Skip to content
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

Merged
merged 14 commits into from
Mar 22, 2020

Conversation

thescientist13
Copy link
Member

@thescientist13 thescientist13 commented Mar 10, 2020

Related Issue

resolves #128

Summary of Changes

Please review this PR in the context of this issue on imperative vs declarative templates. Will use imperative approach for now.

  1. Set default config.title to My App
  2. Move <title> setting to app-template.js
  3. Pull title from data
  4. Added logic / support for per page titles
  5. Added unit tests and test cases
  6. Update documentation

TODO

  1. Handle per page specific <title>
  2. Update unit tests
  3. Documentation
  4. <title> doesn't change on sub sequent page change (need to hook into the router, or better use of lifecycles?) - see have site <head> tags (<meta> / <title> / <script> / etc) update when using staticRouter #306

@thescientist13 thescientist13 added the enhancement Improve something existing (e.g. no docs, new APIs, etc) label Mar 10, 2020
@thescientist13 thescientist13 self-assigned this Mar 10, 2020
@thescientist13 thescientist13 force-pushed the release/0.5.0 branch 2 times, most recently from 50e42a9 to 8d1529a Compare March 15, 2020 23:00
* graphql server working

* apollo client connect to apollo server

* connected header example using lit apollo

* todo

* todos

* query and client + server refactor

* schema refactoring

* clean up console logging

* alias all @greenwood/cli/data module imports

* avoid paramater destructuring

* graphql example in the header

* multiple schemas

* internal data sources documentation

* shelf refactor and children query integration

* refactor out ApolloQuery

* ability to intercept client.query calls

* basic semi-working implementation

* remove extra config from server context

* have puppeteer wait for graphql requests before returning content

* fix and add test cases for apollo

* merged resolvers not actually working

* multiple queries support

* everything working

* todos

* TODO tracking

* fix fallback apollo client fetch handling

* full test suite

* cache json test cases

* stablize test due to inconsistent data results ordering

* clean up deps

* todo cleanup

* remove forced client call in SSG mode for client

* represent graph through the schema

* updated data docs

* typos and grammer

* typos and community link fixes
@thescientist13 thescientist13 force-pushed the enhancement/issue-128-title-from-data branch from 1b65771 to b021588 Compare March 15, 2020 23:47
@thescientist13 thescientist13 changed the title [WIP] Enhancement/issue 128 title from data Enhancement/issue 128 title from data Mar 16, 2020
const id = page.label;

pages.push({
id,
filePath: mdFile,
fileName,
template,
title: label,
title: title !== '' ? title : label,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -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 || '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

const response = await Promise.all([
await client.query({
query: ConfigQuery
}),
Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, two queries here isn't ideal, that said, I think config should stay it's own schema / structure. Mixing it up with the graph may not be super intuitive / maintainable.

However, it would be great if apollo-client could support sending multiple queries for us, then we wouldn't have to use Promise.all but I suppose it could just be a limitation. Would be good to think of another more elegant way if we can think of one.

Copy link
Member Author

@thescientist13 thescientist13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re:

<title> doesn't change on sub sequent page change (need to hook into the router, or better use of lifecycles?)

It looks like we can take influence from the scroll component to listen to browser URL changes and update <title> / <meta> dynamically.

Copy link
Member Author

@thescientist13 thescientist13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we can take influence from the scroll component to listen to browser URL changes and update <title> / dynamically.

Actually, we can't really detect changes like that from window, for something equivalent to a location change and it doesn't look like lit-redux-router uses pushState.

So I guess given that it is a redux implementation, we might need to write a reducer to catch the dispatch / route change?

Copy link
Member Author

@thescientist13 thescientist13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #306 for specifically handling <title> change in SPA mode,

@thescientist13 thescientist13 merged commit 537133a into release/0.5.0 Mar 22, 2020
@thescientist13 thescientist13 deleted the enhancement/issue-128-title-from-data branch March 22, 2020 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content as Data enhancement Improve something existing (e.g. no docs, new APIs, etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants