blazed-past-us 0.7.3 → 0.7.6

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/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  <p align="center">
2
- <img src="https://github.com/gass-git/blazed-past-us/raw/main/bolt.png" width="150">
2
+ <img src="https://github.com/gass-git/blazed-past-us/raw/main/bolt.png" width="100">
3
3
  </p>
4
4
 
5
5
  > 🚧 **Work in progress** This framework is still under active development. Expect changes.
6
6
 
7
7
  # Blazed Past Us..
8
8
 
9
- A static blog framework made for developers that allows content to be written in Markdown directly from the IDE. Plus it's fast.
9
+ Developer centric static blog framework. Write in Markdown from your IDE, share code and SVGs effortlessly, and ship server-rendered HTML for blazing⚡fast load times.
10
10
 
11
11
  ## Commit 0
12
12
 
@@ -38,6 +38,7 @@ _"Very well… let the cosmos bear witness."_
38
38
 
39
39
  ## Useful notes
40
40
 
41
+ - The HTML layout can be modified in `src/layout.js`
41
42
  - Append `/#/?tags=` to the base URL to filter home page posts by tag.
42
43
  - Posts creation dates are persisted.
43
44
  - The creation date is not updated when editing a post.
Binary file
package/dist/cli/build.js CHANGED
@@ -3,7 +3,7 @@ import { parseMarkdown } from '../server/parse-markdown.js';
3
3
  import fs from 'node:fs';
4
4
  import fsPromises from 'node:fs/promises';
5
5
  import path from 'node:path';
6
- import { getPostsRegistry, handlePostsRegistryUpdate, log, postNotInRegistry, } from '../server/server-utils.js';
6
+ import { getPostsRegistry, handlePostsRegistryUpdate, log, postNotInRegistry, sortPostsByNewest, } from '../server/server-utils.js';
7
7
  import { generatePostMetadata, writeTransformedPostFile, } from '../server/file-builder.js';
8
8
  import { getSlug } from '../runtime/getters.js';
9
9
  /**
@@ -37,27 +37,28 @@ async function buildBundle(paths) {
37
37
  const postsFiles = fs.readdirSync(paths.input).filter((f) => f.endsWith('.md'));
38
38
  const data = new Array();
39
39
  const postsRegistry = { data: await getPostsRegistry(paths.input), update: false };
40
+ const date = new Date().toISOString();
40
41
  for (const filename of postsFiles) {
41
42
  const filePath = path.join(paths.input, filename);
42
43
  const parsedPostData = await parseMarkdown(filePath);
43
44
  const htmlFilename = filename.replace('.md', '.html');
44
45
  const slug = getSlug(htmlFilename);
45
- await generatePostMetadata(data, filePath, htmlFilename, parsedPostData.tags, postsRegistry.data);
46
+ await generatePostMetadata(data, filePath, htmlFilename, parsedPostData.tags, postsRegistry.data, date);
46
47
  await fsPromises.mkdir(paths.output, { recursive: true });
47
48
  await writeTransformedPostFile(path.join(paths.output, htmlFilename), parsedPostData.html, filename);
48
49
  if (postNotInRegistry(postsRegistry.data, slug)) {
49
50
  postsRegistry.update = true;
50
- const stats = await fsPromises.stat(filePath);
51
51
  postsRegistry.data?.push({
52
52
  slug: getSlug(htmlFilename),
53
- created: stats.birthtime,
53
+ created: date,
54
54
  });
55
55
  }
56
56
  }
57
57
  if (postsRegistry.update) {
58
58
  handlePostsRegistryUpdate(postsRegistry.data, paths);
59
59
  }
60
- const jsonPosts = JSON.stringify(data);
60
+ const sortedData = sortPostsByNewest(data);
61
+ const jsonPosts = JSON.stringify(sortedData);
61
62
  fs.writeFileSync(path.join(paths.output, '/data.json'), jsonPosts);
62
63
  log('all posts have been parsed into HTML ✅', 'yellow');
63
64
  }
@@ -4,7 +4,8 @@ function render(view, root, views, postsMetadata, postsHTML, postTagsFilter, pos
4
4
  const { home, post, notFound } = views;
5
5
  switch (view) {
6
6
  case 'home':
7
- inject(r, home(postTagsFilter?.split(','), postsMetadata));
7
+ const tags = postTagsFilter?.split(',');
8
+ inject(r, home(tags, postsMetadata));
8
9
  break;
9
10
  case 'post':
10
11
  if (postSlug && postExists(postsMetadata, postSlug)) {
@@ -1,4 +1,4 @@
1
1
  import { PostMetadata, PostsRegistry } from '../types';
2
2
  declare function writeTransformedPostFile(outputPath: string, postHtmlContent: string, filename: string): Promise<void>;
3
- declare function generatePostMetadata(data: Array<PostMetadata>, filePath: string, htmlFilename: string, postTags: string[], persistentPostsMetadata: PostsRegistry | void): Promise<void>;
3
+ declare function generatePostMetadata(data: Array<PostMetadata>, filePath: string, htmlFilename: string, postTags: string[], persistentPostsMetadata: PostsRegistry | void, date: string): Promise<void>;
4
4
  export { generatePostMetadata, writeTransformedPostFile };
@@ -7,11 +7,10 @@ async function writeTransformedPostFile(outputPath, postHtmlContent, filename) {
7
7
  .then(() => console.log(chalk.green(`✔ ${filename}`)))
8
8
  .catch((error) => console.error(error));
9
9
  }
10
- async function generatePostMetadata(data, filePath, htmlFilename, postTags, persistentPostsMetadata) {
11
- const stats = await fsPromises.stat(filePath);
10
+ async function generatePostMetadata(data, filePath, htmlFilename, postTags, persistentPostsMetadata, date) {
12
11
  const fileContent = await fsPromises.readFile(filePath, 'utf-8');
13
12
  const slug = getSlug(htmlFilename);
14
- const createdDate = persistentPostsMetadata?.find((p) => p.slug === slug)?.created || stats.birthtime;
13
+ const createdDate = persistentPostsMetadata?.find((p) => p.slug === slug)?.created || date;
15
14
  data.push({
16
15
  slug: getSlug(htmlFilename),
17
16
  filename: htmlFilename,
@@ -1,4 +1,4 @@
1
- import { MsgColor, PostsPaths, PostsRegistry } from '../types';
1
+ import { MsgColor, PostMetadata, PostsPaths, PostsRegistry } from '../types';
2
2
  import type { Plugin } from 'unified';
3
3
  import type { Root } from 'mdast';
4
4
  declare function postNotInRegistry(registry: PostsRegistry | [] | void, slug: string): boolean;
@@ -7,4 +7,5 @@ declare function getPostsRegistry(postsDirectoryPath: string): Promise<void | Po
7
7
  declare function copyRecursive(src: string, destination: string): void;
8
8
  declare function log(msg: string, color: MsgColor): void;
9
9
  declare const remarkInlineSvg: Plugin<[], Root, Root>;
10
- export { postNotInRegistry, handlePostsRegistryUpdate, getPostsRegistry, copyRecursive, log, remarkInlineSvg, };
10
+ declare function sortPostsByNewest(postsMetadata: PostMetadata[]): PostMetadata[];
11
+ export { postNotInRegistry, handlePostsRegistryUpdate, getPostsRegistry, copyRecursive, log, remarkInlineSvg, sortPostsByNewest, };
@@ -93,4 +93,7 @@ const remarkInlineSvg = function () {
93
93
  });
94
94
  };
95
95
  };
96
- export { postNotInRegistry, handlePostsRegistryUpdate, getPostsRegistry, copyRecursive, log, remarkInlineSvg, };
96
+ function sortPostsByNewest(postsMetadata) {
97
+ return postsMetadata.sort((a, b) => b.created.localeCompare(a.created));
98
+ }
99
+ export { postNotInRegistry, handlePostsRegistryUpdate, getPostsRegistry, copyRecursive, log, remarkInlineSvg, sortPostsByNewest, };
@@ -7,31 +7,6 @@
7
7
  <link rel="icon" type="image/svg+xml" href="./src/assets/favicon.svg" />
8
8
  </head>
9
9
  <body>
10
- <div class="col-flexbox">
11
- <section>
12
- <header>
13
- <div class="logo">
14
- <div class="bolt-wrapper" id="bolt">
15
- <div class="top"></div>
16
- <div class="bottom"></div>
17
- </div>
18
- </div>
19
- <div>
20
- <div class="top">
21
- <a class="title" href="#/"></a>
22
- <div class="subtitle"></div>
23
- </div>
24
- </div>
25
- </header>
26
- <main>
27
- <div id="root"></div>
28
- </main>
29
- </section>
30
- <footer>
31
- <span>Powered by </span><span>⚡</span>
32
- <a href="https://github.com/gass-git/blazed-past-us"> blazed-past-us </a>
33
- </footer>
34
- </div>
35
10
  <script type="module" src="./src/main.js"></script>
36
11
  <script type="module" src="./src/stars.js"></script>
37
12
  </body>
@@ -0,0 +1,29 @@
1
+ export default function layout() {
2
+ return `
3
+ <div class="col-flexbox">
4
+ <section>
5
+ <header>
6
+ <div class="logo">
7
+ <div class="bolt-wrapper" id="bolt">
8
+ <div class="top"></div>
9
+ <div class="bottom"></div>
10
+ </div>
11
+ </div>
12
+ <div>
13
+ <div class="top">
14
+ <a class="title" href="#/"></a>
15
+ <div class="subtitle"></div>
16
+ </div>
17
+ </div>
18
+ </header>
19
+ <main>
20
+ <div id="root"></div>
21
+ </main>
22
+ </section>
23
+ <footer>
24
+ <span>Powered by </span><span>⚡</span>
25
+ <a href="https://github.com/gass-git/blazed-past-us"> blazed-past-us </a>
26
+ </footer>
27
+ </div>
28
+ `;
29
+ }
@@ -2,11 +2,12 @@ import config from './config.json';
2
2
  import * as blazed from 'blazed-past-us';
3
3
  import initRouter from './router';
4
4
  import pkg from '../package.json';
5
+ import layout from './layout';
5
6
 
6
- const root = document.getElementById('root');
7
7
  const { postsMetadata, postsHTML } = await blazed.fetchResources(config);
8
8
 
9
- initRouter(root, postsMetadata, postsHTML);
9
+ blazed.inject(document.body, layout());
10
+ initRouter(document.getElementById('root'), postsMetadata, postsHTML);
10
11
 
11
12
  /**
12
13
  * ----------------------------
@@ -1,5 +1,4 @@
1
1
  @import 'fonts.css';
2
- @import 'media.css';
3
2
  @import 'animations.css';
4
3
  @import 'loader.css';
5
4
  @import 'post.css';
@@ -8,9 +7,11 @@
8
7
  @import 'home.css';
9
8
 
10
9
  :root {
11
- --background: #0f0f23;
10
+ --background: #172330;
12
11
  --max-width: 55rem;
13
12
  --neon: #82f9ff;
13
+ --post-title-color: rgb(241, 241, 241);
14
+ --body-text-color: #ececec;
14
15
  --light-blue-09: rgba(129, 213, 255, 0.9);
15
16
  --light-blue-05: rgba(129, 213, 255, 0.5);
16
17
  --light-yellow: #ffffb4;
@@ -83,3 +84,13 @@ canvas {
83
84
  font-size: 0.85rem;
84
85
  text-transform: uppercase;
85
86
  }
87
+
88
+ @media (max-width: 60rem) {
89
+ header {
90
+ width: clamp(95%, 95%, 95%);
91
+ }
92
+
93
+ section {
94
+ width: clamp(95%, 95%, 95%);
95
+ }
96
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blazed-past-us",
3
- "version": "0.7.3",
3
+ "version": "0.7.6",
4
4
  "description": "A static blog framework made for developers that allows content to be written in Markdown directly from the IDE.",
5
5
  "license": "MIT",
6
6
  "author": "gass-git",
Binary file
@@ -1,5 +0,0 @@
1
- @media (max-width: 60rem) {
2
- header {
3
- width: clamp(100%, 100%, 100%);
4
- }
5
- }