Skip to content

Commit

Permalink
Fix SSR bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
shiro committed Apr 4, 2024
1 parent f63afaa commit 5cac853
Show file tree
Hide file tree
Showing 24 changed files with 375 additions and 100 deletions.
3 changes: 3 additions & 0 deletions app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ export default defineConfig({

vite(options) {
return {
// define: {
// "import.meta.env.BASE_URL": JSON.stringify("/foo"),
// },
css: { postcss: "./postcss.config.js" },
server: {
port: 3000,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
},
"devDependencies": {
"@types/imagemagick": "0.0.35",
"babel-plugin-transform-define": "2.1.4",
"gray-matter": "4.0.3",
"imagemagick": "0.1.3",
"prettier": "3.2.5",
Expand Down
1 change: 1 addition & 0 deletions src/components/SVG.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function getInitialData(src: string, async?: boolean) {
} else {
// if (src.startsWith(config.resourceBaseURL))
// src = src.slice(config.resourceBaseURL.length);
if (src.startsWith(config.base)) src = src.slice(config.base.length);

src = path.join(process.cwd(), "public", src);

Expand Down
1 change: 1 addition & 0 deletions src/entry-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
import { mount, StartClient } from "@solidjs/start/client";

mount(() => <StartClient />, document.getElementById("app")!);
console.log(import.meta.MIB);
32 changes: 32 additions & 0 deletions src/ssg/getArticles.ssg.bundled_63z57dui99b.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// src/ssg/getArticles.ssg.ts
import fs from "fs";
import matter from "gray-matter";
import path from "path";
var base = "./src/articles";
var files = fs.readdirSync(base);
var getArticlesSSG = () => {
return files.map((x) => {
try {
const raw = fs.readFileSync(path.join(base, x, "article.mdx")).toString();
const frontmatter = matter(raw).data;
const title = frontmatter.title ?? raw.match(/# [^\n]*/)[0].slice(2);
const description = raw.match(/# [^\n]+\n+([\s\S]+?)(?=\n\n)/)?.[1];
const url = `/articles/${x.split(".")[0]}`;
const date = x.split("-").slice(0, 3).reverse().join(".");
return { title, url, description, date };
} catch (err) {
}
}).filter(Boolean).reverse();
};
var watchFiles = files.map((x) => path.resolve(base, x, "article.mdx"));
var getArticles_ssg_default = async () => {
return {
data: getArticlesSSG(),
watchFiles
};
};
export {
getArticles_ssg_default as default,
getArticlesSSG
};
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsic3JjL3NzZy9nZXRBcnRpY2xlcy5zc2cudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9faW5qZWN0ZWRfZmlsZW5hbWVfXyA9IFwiL2hvbWUvc2hpcm8vcHJvamVjdC9wb3J0L3NyYy9zc2cvZ2V0QXJ0aWNsZXMuc3NnLnRzXCI7Y29uc3QgX19pbmplY3RlZF9kaXJuYW1lX18gPSBcIi9ob21lL3NoaXJvL3Byb2plY3QvcG9ydC9zcmMvc3NnXCI7Y29uc3QgX19pbmplY3RlZF9pbXBvcnRfbWV0YV91cmxfXyA9IFwiZmlsZTovLy9ob21lL3NoaXJvL3Byb2plY3QvcG9ydC9zcmMvc3NnL2dldEFydGljbGVzLnNzZy50c1wiO2ltcG9ydCBmcyBmcm9tIFwiZnNcIjtcbmltcG9ydCBtYXR0ZXIgZnJvbSBcImdyYXktbWF0dGVyXCI7XG5pbXBvcnQgcGF0aCBmcm9tIFwicGF0aFwiO1xuXG5jb25zdCBiYXNlID0gXCIuL3NyYy9hcnRpY2xlc1wiO1xuY29uc3QgZmlsZXMgPSBmcy5yZWFkZGlyU3luYyhiYXNlKTtcblxuZXhwb3J0IGNvbnN0IGdldEFydGljbGVzU1NHID0gKCkgPT4ge1xuICByZXR1cm4gZmlsZXNcbiAgICAubWFwKCh4KSA9PiB7XG4gICAgICB0cnkge1xuICAgICAgICBjb25zdCByYXcgPSBmc1xuICAgICAgICAgIC5yZWFkRmlsZ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FVO0FBRWpCLElBQU0sT0FBTztBQUNiLElBQU0sUUFBUSxHQUFHLFlBQVksSUFBSTtBQUUxQixJQUFNLGlCQUFpQixNQUFNO0FBQ2xDLFNBQU8sTUFDSixJQUFJLENBQUMsTUFBTTtBQUNWLFFBQUk7QUFDRixZQUFNLE1BQU0sR0FDVCxhQUFhLEtBQUssS0FBSyxNQUFNLEdBQUcsYUFBYSxDQUFDLEVBQzlDLFNBQVM7QUFDWixZQUFNLGNBQWMsT0FBTyxHQUFHLEVBQUU7QUFFaEMsWUFBTSxRQUFRLFlBQVksU0FBUyxJQUFJLE1BQU0sVUFBVSxFQUFHLENBQUMsRUFBRSxNQUFNLENBQUM7QUFDcEUsWUFBTSxjQUFjLElBQUksTUFBTSwrQkFBK0IsSUFBSSxDQUFDO0FBRWxFLFlBQU0sTUFBTSxhQUFhLEVBQUUsTUFBTSxHQUFHLEVBQUUsQ0FBQyxDQUFDO0FBQ3hDLFlBQU0sT0FBTyxFQUFFLE1BQU0sR0FBRyxFQUFFLE1BQU0sR0FBRyxDQUFDLEVBQUUsUUFBUSxFQUFFLEtBQUssR0FBRztBQUN4RCxhQUFPLEVBQUUsT0FBTyxLQUFLLGFBQWEsS0FBSztBQUFBLElBQ3pDLFNBQVMsS0FBSztBQUFBLElBRWQ7QUFBQSxFQUNGLENBQUMsRUFDQSxPQUFPLE9BQU8sRUFDZCxRQUFRO0FBQ2I7QUFDQSxJQUFNLGFBQWEsTUFBTSxJQUFJLENBQUMsTUFBTSxLQUFLLFFBQVEsTUFBTSxHQUFHLGFBQWEsQ0FBQztBQUV4RSxJQUFPLDBCQUFRLFlBQVk7QUFDekIsU0FBTztBQUFBLElBQ0wsTUFBTSxlQUFlO0FBQUEsSUFDckI7QUFBQSxFQUNGO0FBQ0Y7IiwKICAibmFtZXMiOiBbXQp9Cg==
32 changes: 32 additions & 0 deletions src/ssg/getArticles.ssg.bundled_91n3lh5iqun.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// src/ssg/getArticles.ssg.ts
import fs from "fs";
import matter from "gray-matter";
import path from "path";
var base = "./src/articles";
var files = fs.readdirSync(base);
var getArticlesSSG = () => {
return files.map((x) => {
try {
const raw = fs.readFileSync(path.join(base, x, "article.mdx")).toString();
const frontmatter = matter(raw).data;
const title = frontmatter.title ?? raw.match(/# [^\n]*/)[0].slice(2);
const description = raw.match(/# [^\n]+\n+([\s\S]+?)(?=\n\n)/)?.[1];
const url = `/articles/${x.split(".")[0]}`;
const date = x.split("-").slice(0, 3).reverse().join(".");
return { title, url, description, date };
} catch (err) {
}
}).filter(Boolean).reverse();
};
var watchFiles = files.map((x) => path.resolve(base, x, "article.mdx"));
var getArticles_ssg_default = async () => {
return {
data: getArticlesSSG(),
watchFiles
};
};
export {
getArticles_ssg_default as default,
getArticlesSSG
};
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsic3JjL3NzZy9nZXRBcnRpY2xlcy5zc2cudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9faW5qZWN0ZWRfZmlsZW5hbWVfXyA9IFwiL2hvbWUvc2hpcm8vcHJvamVjdC9wb3J0L3NyYy9zc2cvZ2V0QXJ0aWNsZXMuc3NnLnRzXCI7Y29uc3QgX19pbmplY3RlZF9kaXJuYW1lX18gPSBcIi9ob21lL3NoaXJvL3Byb2plY3QvcG9ydC9zcmMvc3NnXCI7Y29uc3QgX19pbmplY3RlZF9pbXBvcnRfbWV0YV91cmxfXyA9IFwiZmlsZTovLy9ob21lL3NoaXJvL3Byb2plY3QvcG9ydC9zcmMvc3NnL2dldEFydGljbGVzLnNzZy50c1wiO2ltcG9ydCBmcyBmcm9tIFwiZnNcIjtcbmltcG9ydCBtYXR0ZXIgZnJvbSBcImdyYXktbWF0dGVyXCI7XG5pbXBvcnQgcGF0aCBmcm9tIFwicGF0aFwiO1xuXG5jb25zdCBiYXNlID0gXCIuL3NyYy9hcnRpY2xlc1wiO1xu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UFPLDBCQUFRLFlBQVk7QUFDekIsU0FBTztBQUFBLElBQ0wsTUFBTSxlQUFlO0FBQUEsSUFDckI7QUFBQSxFQUNGO0FBQ0Y7IiwKICAibmFtZXMiOiBbXQp9Cg==
32 changes: 32 additions & 0 deletions src/ssg/getArticles.ssg.bundled_ctqcxhuz6r5.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// src/ssg/getArticles.ssg.ts
import fs from "fs";
import matter from "gray-matter";
import path from "path";
var base = "./src/articles";
var files = fs.readdirSync(base);
var getArticlesSSG = () => {
return files.map((x) => {
try {
const raw = fs.readFileSync(path.join(base, x, "article.mdx")).toString();
const frontmatter = matter(raw).data;
const title = frontmatter.title ?? raw.match(/# [^\n]*/)[0].slice(2);
const description = raw.match(/# [^\n]+\n+([\s\S]+?)(?=\n\n)/)?.[1];
const url = `/articles/${x.split(".")[0]}`;
const date = x.split("-").slice(0, 3).reverse().join(".");
return { title, url, description, date };
} catch (err) {
}
}).filter(Boolean).reverse();
};
var watchFiles = files.map((x) => path.resolve(base, x, "article.mdx"));
var getArticles_ssg_default = async () => {
return {
data: getArticlesSSG(),
watchFiles
};
};
export {
getArticles_ssg_default as default,
getArticlesSSG
};
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsic3JjL3NzZy9nZXRBcnRpY2xlcy5zc2cudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9faW5qZWN0ZWRfZmlsZW5hbWVfXyA9IFwiL2hvbWUvc2hpcm8vcHJvamVjdC9wb3J0L3NyYy9zc2cvZ2V0QXJ0aWNsZXMuc3NnLnRzXCI7Y29uc3QgX19pbmplY3RlZF9kaXJuYW1lX18gPSBcIi9ob21lL3NoaXJvL3Byb2plY3QvcG9ydC9zcmMvc3NnXCI7Y29uc3QgX19pbmplY3RlZF9pbXBvcnRfbWV0YV91cmxfXyA9IFwiZmlsZTovLy9ob21lL3NoaXJvL3Byb2plY3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WEsS0FBSztBQUFBLElBQ3pDLFNBQVMsS0FBSztBQUFBLElBRWQ7QUFBQSxFQUNGLENBQUMsRUFDQSxPQUFPLE9BQU8sRUFDZCxRQUFRO0FBQ2I7QUFDQSxJQUFNLGFBQWEsTUFBTSxJQUFJLENBQUMsTUFBTSxLQUFLLFFBQVEsTUFBTSxHQUFHLGFBQWEsQ0FBQztBQUV4RSxJQUFPLDBCQUFRLFlBQVk7QUFDekIsU0FBTztBQUFBLElBQ0wsTUFBTSxlQUFlO0FBQUEsSUFDckI7QUFBQSxFQUNGO0FBQ0Y7IiwKICAibmFtZXMiOiBbXQp9Cg==
32 changes: 32 additions & 0 deletions src/ssg/getArticles.ssg.bundled_mn9geyqkiu.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// src/ssg/getArticles.ssg.ts
import fs from "fs";
import matter from "gray-matter";
import path from "path";
var base = "./src/articles";
var files = fs.readdirSync(base);
var getArticlesSSG = () => {
return files.map((x) => {
try {
const raw = fs.readFileSync(path.join(base, x, "article.mdx")).toString();
const frontmatter = matter(raw).data;
const title = frontmatter.title ?? raw.match(/# [^\n]*/)[0].slice(2);
const description = raw.match(/# [^\n]+\n+([\s\S]+?)(?=\n\n)/)?.[1];
const url = `/articles/${x.split(".")[0]}`;
const date = x.split("-").slice(0, 3).reverse().join(".");
return { title, url, description, date };
} catch (err) {
}
}).filter(Boolean).reverse();
};
var watchFiles = files.map((x) => path.resolve(base, x, "article.mdx"));
var getArticles_ssg_default = async () => {
return {
data: getArticlesSSG(),
watchFiles
};
};
export {
getArticles_ssg_default as default,
getArticlesSSG
};
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsic3JjL3NzZy9nZXRBcnRpY2xlcy5zc2cudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9faW5qZWN0ZWRfZmlsZW5hbWVfXyA9IFwiL2hvbWUvc2hpcm8vcHJvamVjdC9wb3J0L3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xFLFlBQU0sTUFBTSxhQUFhLEVBQUUsTUFBTSxHQUFHLEVBQUUsQ0FBQyxDQUFDO0FBQ3hDLFlBQU0sT0FBTyxFQUFFLE1BQU0sR0FBRyxFQUFFLE1BQU0sR0FBRyxDQUFDLEVBQUUsUUFBUSxFQUFFLEtBQUssR0FBRztBQUN4RCxhQUFPLEVBQUUsT0FBTyxLQUFLLGFBQWEsS0FBSztBQUFBLElBQ3pDLFNBQVMsS0FBSztBQUFBLElBRWQ7QUFBQSxFQUNGLENBQUMsRUFDQSxPQUFPLE9BQU8sRUFDZCxRQUFRO0FBQ2I7QUFDQSxJQUFNLGFBQWEsTUFBTSxJQUFJLENBQUMsTUFBTSxLQUFLLFFBQVEsTUFBTSxHQUFHLGFBQWEsQ0FBQztBQUV4RSxJQUFPLDBCQUFRLFlBQVk7QUFDekIsU0FBTztBQUFBLElBQ0wsTUFBTSxlQUFlO0FBQUEsSUFDckI7QUFBQSxFQUNGO0FBQ0Y7IiwKICAibmFtZXMiOiBbXQp9Cg==
1 change: 0 additions & 1 deletion src/ssg/getArticles.ssg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const getArticlesSSG = () => {

const title = frontmatter.title ?? raw.match(/# [^\n]*/)![0].slice(2);
const description = raw.match(/# [^\n]+\n+([\s\S]+?)(?=\n\n)/)?.[1];
console.log(description);

const url = `/articles/${x.split(".")[0]}`;
const date = x.split("-").slice(0, 3).reverse().join(".");
Expand Down
Loading

0 comments on commit 5cac853

Please sign in to comment.