Comments (2)
I've found that there is a couple of properties missing in the library for retrieving data for the pages on the docs.
Apparently, some work was done to get this properties but then is discarded. I've include those properties again and seems to be working, however, I export both properties with the same value as it doesn't look like I need the "path" formatting that is done in the svelte docs
Please note that there is still a TODO
// TODO this should probably use a type from site-kit
because apparently we extend the original component type with a new category
property, nonetheless, now it satisfies the type and should work.
This could be my first PR to open source. Any tips?
export const categories = {};
export const pages = {};
for (const [file, asset] of Object.entries(meta)) {
const slug = /\/\d{2}-(.+)\/meta\.json$/.exec(file)[1];
const { title, draft } = await read(asset).json();
if (draft) continue;
categories[slug] = {
title,
pages: []
};
}
for (const [file, asset] of Object.entries(markdown)) {
const [, category_dir, basename] = /\/(\d{2}-.+?)\/(\d{2}-.+\.md)$/.exec(file);
const category_slug = category_dir.slice(3);
const slug = basename.slice(3, -3); // strip the number prefix and .md suffix
const category = categories[category_slug];
if (!category) continue; // draft
const {
metadata: { draft, title, rank },
body
} = extractFrontmatter(await read(asset).text());
if (draft === 'true') continue;
category.pages.push({
title,
path: `${base}/docs/${slug}`
});
pages[slug] = {
rank: +rank || undefined,
category: category.title,
title,
file: `${category_dir}/${basename}`,
slug,
path: slug,
sections: await get_sections(body),
body
};
}
/** @param {string} slug */
export async function get_parsed_docs(slug) {
const page = pages[slug];
if (!page) error(404);
// TODO this should probably use a type from site-kit
return {
category: page.category,
title: page.title,
file: page.file,
path: page.path,
slug: page.slug,
sections: page.sections,
content: await render_content(page.file, page.body)
};
}
from site-kit.
Since this is a problem with the kit repo I'll reopen the issue and solve it there.
from site-kit.
Related Issues (20)
- search shows inconsistent state
- Strange menu scrollbar behavior on Svelte docs page HOT 2
- Scroll position lost when navigating back from documentation to a blog post
- Output toggle CSS doesn't hide system styles
- Docs: Scrollbar behind header HOT 1
- Home Link is off center
- Markdown renderer prevents some translations from outside
- Broken link in search results
- docs: copy code button does not stay in place when scrolling horizontally
- docs: copy code button does not include linebreaks in the copied text HOT 3
- Site: sidebar nav on migration page doesn't work HOT 2
- Link replacement
- "<" and ">" don't render properly in searchbox
- Cannot interact with the scrollbar in kit.svelte.dev/docs HOT 1
- Links on site cannot be selected HOT 2
- Link color on site is inaccessible HOT 1
- Local & Session Storage not working
- Error: loadAndValidateConfig() has been deprecated in favor of loadConfiguration() and createConfiguration().
- Nav from $layout throws an TypeError in $error page.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from site-kit.