Metadata parsing and types update
This commit is contained in:
parent
22e59b089f
commit
c04d27265b
|
@ -10,5 +10,5 @@ export interface OpenGraphMetadata {
|
|||
imageType: OGImageType;
|
||||
imageWidth: OGImageWidth;
|
||||
imageHeight: OGImageHeight;
|
||||
url: string;
|
||||
canonical: string;
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@ import type { MarkdownMetadata } from '$lib/types/mdMetadata';
|
|||
import type { OpenGraphMetadata } from '$lib/types/ogMetadata';
|
||||
|
||||
// Base service item type
|
||||
export interface Service {
|
||||
export type Service = {
|
||||
title: string;
|
||||
description: string;
|
||||
id: string;
|
||||
|
|
|
@ -40,30 +40,3 @@ export const readJsonFile = async (filePath: string) => {
|
|||
const jsonData = await fs.readFileSync(path.join(process.cwd(), 'src', 'content', filePath), 'utf-8');
|
||||
return JSON.parse(jsonData);
|
||||
}
|
||||
|
||||
// ======= MARKDOWN PARSER ========
|
||||
|
||||
// https://github.com/jonschlinkert/gray-matter
|
||||
import * as matter from 'gray-matter';
|
||||
// https://github.com/markedjs/marked
|
||||
// import marked from 'marked';
|
||||
|
||||
export const parseMarkdownFile = async (filePath: string) => {
|
||||
const markdownData = await fs.readFileSync(path.join(process.cwd(), 'src', 'content', filePath), 'utf-8');
|
||||
const { data, content } = matter(markdownData);
|
||||
return { frontmatter: data, content };
|
||||
}
|
||||
// export function parseMarkdown<T>(filePath: string): { frontmatter: T; content: string } {
|
||||
// const data = matter.read(filePath).data;
|
||||
// return {
|
||||
// frontmatter: data as T,
|
||||
// };
|
||||
// }
|
||||
// export function parseMarkdownFile(filePath: string) {
|
||||
// const markdownData = fs.readFileSync(path.join(process.cwd(), filePath), 'utf-8');
|
||||
// const { data, content } = grayMatter(markdownData);
|
||||
|
||||
// return { frontmatter: data, content };
|
||||
// }
|
||||
|
||||
console.log(parseMarkdownFile('../../content/permanentni-make-up/pmu/pmu.md'))
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
// ======= MARKDOWN PARSER ========
|
||||
|
||||
// https://github.com/jonschlinkert/gray-matter
|
||||
import matter from 'gray-matter';
|
||||
// https://github.com/markedjs/marked;- unused
|
||||
// import marked from 'marked';
|
||||
import fs from 'fs';
|
||||
import path from 'path'
|
||||
|
||||
export const parseMarkdownFile = async (filePath: string) => {
|
||||
const markdownData = fs.readFileSync(path.join(process.cwd(), 'src', 'content', filePath), 'utf-8');
|
||||
const { data, content } = matter(markdownData);
|
||||
return { frontmatter: data, content };
|
||||
}
|
||||
// export function parseMarkdown<T>(filePath: string): { frontmatter: T; content: string } {
|
||||
// const data = matter.read(filePath).data;
|
||||
// return {
|
||||
// frontmatter: data as T,
|
||||
// };
|
||||
// }
|
||||
console.log(parseMarkdownFile('../../content/permanentni-make-up/pmu/pmu.md'))
|
Loading…
Reference in New Issue