-
Notifications
You must be signed in to change notification settings - Fork 85
feat: allow ordering to be config based in addition to folder based #79
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
Changes from all commits
7226e75
3db8a1e
4c719fe
5523f95
ea6d42b
bfe1f11
84fbdcc
9170756
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 |
---|---|---|
|
@@ -3,10 +3,9 @@ import { getTutorial } from '../utils/content'; | |
|
||
const tutorial = await getTutorial(); | ||
|
||
const parts = Object.values(tutorial.parts); | ||
const part = parts[0]; | ||
const chapter = part.chapters[1]; | ||
const lesson = chapter.lessons[1]; | ||
const part = tutorial.parts[tutorial.firstPartId!]; | ||
const chapter = part.chapters[part?.firstChapterId!]; | ||
const lesson = chapter.lessons[chapter?.firstLessonId!]; | ||
Comment on lines
+7
to
+8
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. I'm very confused. So all the Also, what if they are defined but they don't exist? Then 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. Correct! It's actually the same behaviour as before because there would be no part either. Note to be in that situation you must not have a part, nor a lesson nor a chapter. Because if you have any, the |
||
|
||
const redirect = `/${part.slug}/${chapter.slug}/${lesson.slug}`; | ||
--- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Largely taken from Astro logger implementation. | ||
* | ||
* @see https://github.com/withastro/astro/blob/c44f7f4babbb19350cd673241136bc974b012d51/packages/astro/src/core/logger/core.ts#L200 | ||
*/ | ||
|
||
import { blue, bold, dim, red, yellow } from 'kleur/colors'; | ||
|
||
const dateTimeFormat = new Intl.DateTimeFormat([], { | ||
hour: '2-digit', | ||
minute: '2-digit', | ||
second: '2-digit', | ||
hour12: false, | ||
}); | ||
|
||
function getEventPrefix(level: 'info' | 'error' | 'warn', label: string) { | ||
const timestamp = `${dateTimeFormat.format(new Date())}`; | ||
const prefix = []; | ||
|
||
if (level === 'error' || level === 'warn') { | ||
prefix.push(bold(timestamp)); | ||
prefix.push(`[${level.toUpperCase()}]`); | ||
} else { | ||
prefix.push(timestamp); | ||
} | ||
|
||
if (label) { | ||
prefix.push(`[${label}]`); | ||
} | ||
|
||
if (level === 'error') { | ||
return red(prefix.join(' ')); | ||
} | ||
if (level === 'warn') { | ||
return yellow(prefix.join(' ')); | ||
} | ||
|
||
if (prefix.length === 1) { | ||
return dim(prefix[0]); | ||
} | ||
return dim(prefix[0]) + ' ' + blue(prefix.splice(1).join(' ')); | ||
} | ||
|
||
export const logger = { | ||
warn(message: string) { | ||
console.log(getEventPrefix('warn', 'tutorialkit') + ' ' + message); | ||
}, | ||
error(message: string) { | ||
console.error(getEventPrefix('error', 'tutorialkit') + ' ' + message); | ||
}, | ||
info(message: string) { | ||
console.log(getEventPrefix('info', 'tutorialkit') + ' ' + message); | ||
}, | ||
}; |
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.
Why was this 1-based?
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.
The folder were expected to start at
1
. We now instead pick the first folder that comes up. It could start at anything: 0, 4, ... or be explicitly defined.So this is a new tiny feature! 😃