blazed-past-us 0.3.9 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/build.js +1 -2
- package/dist/engine/getters.d.ts +5 -5
- package/dist/engine/getters.js +2 -2
- package/dist/engine/render.d.ts +2 -2
- package/dist/engine/render.js +2 -2
- package/dist/server/file-builder.d.ts +2 -2
- package/dist/template/src/router.js +7 -5
- package/dist/template/src/stars.js +1 -1
- package/dist/template/src/views/home.js +2 -2
- package/package.json +1 -1
package/dist/cli/build.js
CHANGED
|
@@ -29,7 +29,7 @@ function initPaths(root) {
|
|
|
29
29
|
/**
|
|
30
30
|
* Processes all post files:
|
|
31
31
|
*
|
|
32
|
-
*
|
|
32
|
+
* Parses Markdown to HTML, generates metadata,
|
|
33
33
|
* writes transformed files, and emits a JSON index.
|
|
34
34
|
*/
|
|
35
35
|
async function buildBundle(paths) {
|
|
@@ -37,7 +37,6 @@ async function buildBundle(paths) {
|
|
|
37
37
|
const data = [];
|
|
38
38
|
for (const filename of postsFiles) {
|
|
39
39
|
const filePath = path.join(paths.input, filename);
|
|
40
|
-
// const postHtmlContent = await parseMarkdown(filePath);
|
|
41
40
|
const parsedPostData = await parseMarkdown(filePath);
|
|
42
41
|
const htmlFilename = filename.replace('.md', '.html');
|
|
43
42
|
await generatePostMetadata(data, filePath, htmlFilename, parsedPostData.tags);
|
package/dist/engine/getters.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare function getPostData(postsMetaData:
|
|
3
|
-
declare function getAllPostsHTML(postsMetaData:
|
|
1
|
+
import type { PostMetaData, Config, PostDataType } from '../types';
|
|
2
|
+
declare function getPostData(postsMetaData: PostMetaData[], slug: string, option: PostDataType): string | Date | undefined;
|
|
3
|
+
declare function getAllPostsHTML(postsMetaData: PostMetaData[], baseURL: string): Promise<{
|
|
4
4
|
slug: string;
|
|
5
5
|
html: string | void;
|
|
6
6
|
}[]>;
|
|
7
|
-
declare function getPostsMetaData(baseURL: string, config: Config): Promise<
|
|
7
|
+
declare function getPostsMetaData(baseURL: string, config: Config): Promise<PostMetaData[]>;
|
|
8
8
|
declare function getSlug(htmlFilename: string): string;
|
|
9
9
|
declare function getTitle(htmlFilename: string): string;
|
|
10
10
|
declare function getBrief(fileContent: string, lines: number): string;
|
|
11
11
|
declare function getTags(fileContent: string): string[];
|
|
12
|
-
declare function getColoredTagsHTML(tags: string,
|
|
12
|
+
declare function getColoredTagsHTML(tags: string, config: Config): string;
|
|
13
13
|
export { getPostData, getAllPostsHTML, getPostsMetaData, getTitle, getTags, getBrief, getColoredTagsHTML, getSlug, };
|
package/dist/engine/getters.js
CHANGED
|
@@ -54,13 +54,13 @@ function getTags(fileContent) {
|
|
|
54
54
|
?.split(',')
|
|
55
55
|
.map((str) => str.trim()) || []);
|
|
56
56
|
}
|
|
57
|
-
function getColoredTagsHTML(tags,
|
|
57
|
+
function getColoredTagsHTML(tags, config) {
|
|
58
58
|
return tags
|
|
59
59
|
.replace(/\s/g, '')
|
|
60
60
|
.toLowerCase()
|
|
61
61
|
.split(',')
|
|
62
62
|
.map((key) => {
|
|
63
|
-
const tagColor =
|
|
63
|
+
const tagColor = config.tags[key]?.color ?? config.tags.default.color;
|
|
64
64
|
return `
|
|
65
65
|
<span class="tag" style="--tag-color: ${tagColor}">
|
|
66
66
|
${key}
|
package/dist/engine/render.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare function render(view:
|
|
1
|
+
import { Views, PostMetaData } from '../types.js';
|
|
2
|
+
declare function render(view: string, root: HTMLElement, views: Views, postsMetaData: PostMetaData[], postTagsFilter?: string, postSlug?: string): void;
|
|
3
3
|
export { render };
|
package/dist/engine/render.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { postExists, inject } from './utils.js';
|
|
2
|
-
function render(view, root, views, postsMetaData,
|
|
2
|
+
function render(view, root, views, postsMetaData, postTagsFilter, postSlug) {
|
|
3
3
|
const r = root;
|
|
4
4
|
const { home, post, notFound } = views;
|
|
5
5
|
switch (view) {
|
|
6
6
|
case 'home':
|
|
7
|
-
inject(r, home(
|
|
7
|
+
inject(r, home(postTagsFilter?.split(',')));
|
|
8
8
|
break;
|
|
9
9
|
case 'post':
|
|
10
10
|
if (postSlug && postExists(postsMetaData, postSlug)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PostMetaData } from '../types';
|
|
2
2
|
declare function writeTransformedPostFile(outputPath: string, postHtmlContent: string, filename: string): Promise<void>;
|
|
3
|
-
declare function generatePostMetadata(data: Array<
|
|
3
|
+
declare function generatePostMetadata(data: Array<PostMetaData>, filePath: string, htmlFilename: string, postTags: string[]): Promise<void>;
|
|
4
4
|
export { generatePostMetadata, writeTransformedPostFile };
|
|
@@ -18,12 +18,14 @@ export default function initRouter(root, postsMetaData) {
|
|
|
18
18
|
* This is the reason why we use hash routing.
|
|
19
19
|
*/
|
|
20
20
|
async function handleRoute(root, postsMetaData) {
|
|
21
|
-
const
|
|
22
|
-
const
|
|
21
|
+
const hashRoute = window.location.hash;
|
|
22
|
+
const pathname = getPathname(hashRoute);
|
|
23
|
+
const queryString = hashRoute.split('?')[1] || '';
|
|
24
|
+
const urlParams = new URLSearchParams(queryString);
|
|
23
25
|
const views = { home, post, notFound };
|
|
24
26
|
|
|
25
|
-
if (pathname === '' || pathname === 'home') {
|
|
26
|
-
render('home', root, views, postsMetaData, urlParams.get('
|
|
27
|
+
if (pathname === '' || pathname === 'home' || queryString) {
|
|
28
|
+
render('home', root, views, postsMetaData, urlParams.get('tags'));
|
|
27
29
|
return;
|
|
28
30
|
}
|
|
29
31
|
|
|
@@ -36,6 +38,6 @@ async function handleRoute(root, postsMetaData) {
|
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
// Removes "#/" from the location hash.
|
|
39
|
-
function
|
|
41
|
+
function getPathname(locationHash) {
|
|
40
42
|
return locationHash.split('/').splice(1).join('/');
|
|
41
43
|
}
|
|
@@ -158,7 +158,7 @@ function handleResize(renderer, camera) {
|
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
// This avoids stars
|
|
161
|
+
// This avoids stars twinkling together.
|
|
162
162
|
function createRandomStarPhases(n, max) {
|
|
163
163
|
const pauses = new Float32Array(n);
|
|
164
164
|
pauses.forEach((_el, i) => (pauses[i] = Math.random() * max + 1));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { postsMetaData } from '../main';
|
|
2
2
|
import { beautifyDate } from 'blazed-past-us';
|
|
3
3
|
|
|
4
|
-
export default function home(
|
|
4
|
+
export default function home(tags) {
|
|
5
5
|
const baseURL = import.meta.env.BASE_URL;
|
|
6
6
|
|
|
7
7
|
const postsHtmlArray = postsMetaData
|
|
8
|
-
.filter((post) => (
|
|
8
|
+
.filter((post) => (tags ? tags.some((tag) => post.tags.includes(tag)) : true))
|
|
9
9
|
.map(
|
|
10
10
|
(post) => `
|
|
11
11
|
<a href="${baseURL}#/${post.slug}">
|
package/package.json
CHANGED