added PageTop component, markdown styles, white background on logo svg, and documentation comments
This commit is contained in:
65
utils/asyncDatabase.ts
Normal file
65
utils/asyncDatabase.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* Wrapper functions for asynchronous database operations
|
||||
* @module utils/asyncDatabase
|
||||
*/
|
||||
|
||||
import sqlite3 from "sqlite3";
|
||||
|
||||
/** Callback function type for {@link asyncDatabaseRead} */
|
||||
type asyncDatabaseRowsCallbackFunction = (rows: any[]) => any;
|
||||
/** Callback function type for {@link asyncDatabaseWrite} */
|
||||
type asyncDatabaseVoidCallbackFunction = () => any;
|
||||
|
||||
/**
|
||||
* Wrapper functions that perform read operations to database asynchronously
|
||||
* @template Type
|
||||
* @param {sqlite3.Database} database sqlite3 database object
|
||||
* @param {string} sqlQuery SQL query to execute
|
||||
* @param {asyncDatabaseRowsCallbackFunction} callback callback to perform further operations on each row
|
||||
* @returns {Promise<Type>} Promise for database operation
|
||||
*/
|
||||
const asyncDatabaseRead = <Type>(
|
||||
database: sqlite3.Database,
|
||||
sqlQuery: string,
|
||||
callback: asyncDatabaseRowsCallbackFunction
|
||||
): Promise<Type> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
database.all(sqlQuery, (err: any, rows) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(callback(rows));
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper functions that perform write operations to database asynchronously
|
||||
* @template Type
|
||||
* @param {sqlite3.Database} database sqlite3 database object
|
||||
* @param {string} sqlQuery SQL query to execute
|
||||
* @param {asyncDatabaseVoidCallbackFunction} callback callback to perform after the operation
|
||||
* @returns {Promise<Type>} Promise for database operation
|
||||
*/
|
||||
const asyncDatabaseWrite = <Type>(
|
||||
database: sqlite3.Database,
|
||||
sqlQuery: string,
|
||||
callback: asyncDatabaseVoidCallbackFunction
|
||||
): Promise<Type> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
database.run(sqlQuery, (err: any) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(callback());
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export { asyncDatabaseRead, asyncDatabaseWrite };
|
||||
export type {
|
||||
asyncDatabaseRowsCallbackFunction,
|
||||
asyncDatabaseVoidCallbackFunction,
|
||||
};
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
/**
|
||||
* Enum for interaction mode of DropDown component
|
||||
* @readonly
|
||||
* @enum {string}
|
||||
*/
|
||||
export const enum DropDownMode {
|
||||
@@ -14,6 +15,7 @@ export const enum DropDownMode {
|
||||
|
||||
/**
|
||||
* Enum for alignment of DropDown component
|
||||
* @readonly
|
||||
* @enum {number}
|
||||
*/
|
||||
export const enum DropDownAlignment {
|
||||
@@ -24,8 +26,8 @@ export const enum DropDownAlignment {
|
||||
/**
|
||||
* Interface for the entry of DropDown menu
|
||||
* @typedef {object} DropDownEntry
|
||||
* @property {string} text - Text to be displayed on the menu
|
||||
* @property {string} link - Hyperlink to the page
|
||||
* @property {string} text Text to be displayed on the menu
|
||||
* @property {string} link Hyperlink to the page
|
||||
*/
|
||||
interface DropDownEntry {
|
||||
text: string;
|
||||
@@ -35,11 +37,11 @@ interface DropDownEntry {
|
||||
/**
|
||||
* Interface for the property of DropDown component
|
||||
* @typedef {object} DropDownProperty
|
||||
* @property {string} label - Label of the component
|
||||
* @property {(DropDownMode | string)} mode - Interaction mode of the component
|
||||
* @property {Array<DropDownEntry>} entries - Entries of DropDown menu
|
||||
* @property {boolean} showInMobile - Whether to show the component in mobile(<640px) environemnt
|
||||
* @property {(DropDownAlignment | number)=} alignment - Explicitly assign the alignment of the component
|
||||
* @property {string} label Label of the component
|
||||
* @property {(DropDownMode | string)} mode Interaction mode of the component
|
||||
* @property {Array<DropDownEntry>} entries Entries of DropDown menu
|
||||
* @property {boolean} showInMobile Whether to show the component in mobile(<640px) environemnt
|
||||
* @property {(DropDownAlignment | number)=} alignment Explicitly assign the alignment of the component
|
||||
*/
|
||||
interface DropDownProperty {
|
||||
label: string;
|
||||
|
||||
48
utils/generateSeoMeta.ts
Normal file
48
utils/generateSeoMeta.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Helper function to generate object for useSeoMeta composable
|
||||
* @module utils/generateSeoMeta
|
||||
*/
|
||||
|
||||
import type { UseSeoMetaInput } from "@unhead/schema";
|
||||
|
||||
/**
|
||||
* Generate object for useSeoMeta composable
|
||||
* @typedef {"website" | "article"} ContentType
|
||||
* @param {string} title Title of the page
|
||||
* @param {string} description description of the page
|
||||
* @param {string} imagePath path to image for SNS card, root is at public/
|
||||
* @param {ContentType} [type] Type of website, either website or article, defaults to website if not passed
|
||||
* @returns {UseSeoMetaInput} object that can be passed to useSeoMeta composable
|
||||
* @example
|
||||
* useSeoMeta(
|
||||
* generateSeoMeta(
|
||||
* "Home",
|
||||
* "Home page for my website",
|
||||
* "/default_card_image.png"
|
||||
* )
|
||||
* );
|
||||
* @example
|
||||
* useSeoMeta(generateSeoMeta(data.articleName, data.articleDescription, data.articleCoverImage, "article"));
|
||||
* @function
|
||||
*/
|
||||
export function generateSeoMeta(
|
||||
title: string,
|
||||
description: string,
|
||||
imagePath: string,
|
||||
type?: "website" | "article"
|
||||
): UseSeoMetaInput {
|
||||
return {
|
||||
title: title,
|
||||
ogTitle: title + " - 岐阜高専宇宙工学研究会",
|
||||
twitterTitle: title + " - 岐阜高専宇宙工学研究会",
|
||||
description: description,
|
||||
ogDescription: description,
|
||||
twitterDescription: description,
|
||||
ogImage: imagePath,
|
||||
twitterImage: imagePath,
|
||||
twitterCard: "summary",
|
||||
charset: "utf-8",
|
||||
ogLocale: "ja_JP",
|
||||
ogType: type || "website",
|
||||
};
|
||||
}
|
||||
49
utils/news.ts
Normal file
49
utils/news.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Types for news data
|
||||
* @module utils/news
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enumeration for news entry type of either article or tweet style
|
||||
* @readonly
|
||||
* @enum {number}
|
||||
*/
|
||||
export const enum EntryType {
|
||||
Article,
|
||||
Tweet,
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for article information
|
||||
* @typedef {object} ArticleInfo
|
||||
* @property {number | null} date Unix time of article creation
|
||||
* @property {string | null} article content of article itself
|
||||
* @property {string | null} linkPath path to the article
|
||||
* @property {string | null} coverImagePath Path to the cover image
|
||||
*/
|
||||
interface ArticleInfo {
|
||||
date: number | null;
|
||||
cardContent: string | null;
|
||||
article: string | null;
|
||||
linkPath: string | null;
|
||||
coverImagePath: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for news
|
||||
* @typedef {object} NewsEntry
|
||||
* @property {number | null} date Unix time of creation
|
||||
* @property {EntryType | null} entryType Type of news
|
||||
* @property {string | null} cardContent Content displayed on card
|
||||
* @property {string | null} linkPath Link path to the article
|
||||
* @property {string | null} coverImagePath Path to the cover image
|
||||
*/
|
||||
interface NewsEntry {
|
||||
date: number | null;
|
||||
entryType: EntryType | null;
|
||||
cardContent: string | null;
|
||||
linkPath: string | null;
|
||||
coverImagePath: string | null;
|
||||
}
|
||||
|
||||
export type { ArticleInfo, NewsEntry };
|
||||
18
utils/newsCard.ts
Normal file
18
utils/newsCard.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Type for NewsCard component
|
||||
* @module utils/newsCard
|
||||
*/
|
||||
|
||||
import type { NewsEntry } from "./news";
|
||||
|
||||
/**
|
||||
* Interface that defines property for NewsCard component
|
||||
* @property {NewsEntry} newsEntry Data of news
|
||||
* @property {boolean} isNew Mark the entry new
|
||||
*/
|
||||
interface NewsCardProperty {
|
||||
newsEntry: NewsEntry;
|
||||
isNew: boolean;
|
||||
}
|
||||
|
||||
export type { NewsCardProperty };
|
||||
16
utils/pageTop.ts
Normal file
16
utils/pageTop.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Types for PageTop component
|
||||
* @module utils/pageTop
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface that defines property for PageTop component
|
||||
* @property {string} text Text to show in top
|
||||
* @property {string} imagePath Path to image used in background
|
||||
*/
|
||||
interface PageTopProperty {
|
||||
text: string;
|
||||
imagePath: string;
|
||||
}
|
||||
|
||||
export type { PageTopProperty };
|
||||
Reference in New Issue
Block a user