-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rfc/issue 1167 content as data (#1266)
* initial implementation of content collections with rich frontmatter support * add test cases for collections and prerendering * rename interpolateFrontmatter to activeFrontmatter * refactor id and lable graph properties * refactor graph title behavior * full graph and graphql plugin refactoring * update website for new graph refactoring * make sure active frontmatter is enabled for title substition * restore header nav ordering * comment cleanup * eslint ignore * support multiple import maps * add id to graph and refactor usage * refactoring pagePath to pageHref * update test cases * rename data/queries.js to client.js * handle default title from graph and provide default graph content as data in layouts * handle default title from graph and provide default graph content as data in layouts * refactor content as data handling to its own plugin * refactor for better windows interop * misc refactoring for active frontmatter * refactor outputPath to outputHref * add labels for custom side nav output * refresh content as data and GraphQL docs * update for new docs redirects * filter hidden files and improve unsupported page format detection message * opt-on content as data config and misc refactoring and TODOs * rename test case * update docs for content as data config option and patterns * conslidate content as data into dev server * misc refactoring * content as data import map test cases * fix selectors in test cases * rename test cases * consolidate configuration options and update docs * rename test cases
- Loading branch information
1 parent
76ff3a1
commit 0a96e8e
Showing
187 changed files
with
2,666 additions
and
2,617 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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const CONTENT_STATE = globalThis.__CONTENT_AS_DATA_STATE__ ?? false; // eslint-disable-line no-underscore-dangle | ||
const PORT = globalThis?.__CONTENT_SERVER__?.PORT ?? 1985; // eslint-disable-line no-underscore-dangle | ||
const BASE_PATH = globalThis?.__GWD_BASE_PATH__ ?? ''; // eslint-disable-line no-underscore-dangle | ||
|
||
async function getContentAsData(key = '') { | ||
return CONTENT_STATE | ||
? await fetch(`${window.location.origin}${BASE_PATH}/data-${key.replace(/\//g, '_')}.json`) | ||
.then(resp => resp.json()) | ||
: await fetch(`http://localhost:${PORT}${BASE_PATH}/___graph.json`, { headers: { 'X-CONTENT-KEY': key } }) | ||
.then(resp => resp.json()); | ||
} | ||
|
||
async function getContent() { | ||
return await getContentAsData('graph'); | ||
} | ||
|
||
async function getContentByCollection(collection = '') { | ||
return await getContentAsData(`collection-${collection}`); | ||
} | ||
|
||
async function getContentByRoute(route = '') { | ||
return await getContentAsData(`route-${route}`); | ||
} | ||
|
||
export { getContent, getContentByCollection, getContentByRoute }; |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const activeFrontmatterKeys = ['route', 'label', 'title', 'id']; | ||
|
||
function cleanContentCollection(collection = []) { | ||
return collection.map((page) => { | ||
let prunedPage = {}; | ||
|
||
Object.keys(page).forEach((key) => { | ||
if ([...activeFrontmatterKeys, 'data'].includes(key)) { | ||
prunedPage[key] = page[key]; | ||
} | ||
}); | ||
|
||
return { | ||
...prunedPage, | ||
title: prunedPage.title || prunedPage.label | ||
}; | ||
}); | ||
} | ||
|
||
export { | ||
activeFrontmatterKeys, | ||
cleanContentCollection | ||
}; |
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
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
Oops, something went wrong.