updated packages and added markdown support on card content

This commit is contained in:
2024-09-27 00:07:24 +09:00
parent e1cac6ff05
commit e512da9a48
4 changed files with 34 additions and 17 deletions

View File

@@ -16,7 +16,7 @@ app.use(express.static(path.join(__dirname, "../public")));
app.get('/api/news-list', async (request, response) => {
const database = new sqlite3.Database(path.join(__dirname, "../assets/databases/news.db"));
const sqlQuery = `SELECT * FROM news;`;
const sqlQuery = `SELECT * FROM news ORDER BY date DESC;`;
try {
const result = await asyncDatabaseRead(database, sqlQuery, (rows) => {
let ret = "";

View File

@@ -1830,9 +1830,9 @@
}
},
"node_modules/node-abi": {
"version": "3.67.0",
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.67.0.tgz",
"integrity": "sha512-bLn/fU/ALVBE9wj+p4Y21ZJWYFjUXLXPi/IewyLZkx3ApxKDNBWCKdReeKOtD8dWpOdDCeMyLh6ZewzcLsG2Nw==",
"version": "3.68.0",
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.68.0.tgz",
"integrity": "sha512-7vbj10trelExNjFSBm5kTvZXXa7pZyKWx9RCKIyqe6I9Ev3IzGpQoqBP3a+cOdxY+pWj6VkP28n/2wWysBHD/A==",
"license": "MIT",
"dependencies": {
"semver": "^7.3.5"
@@ -1873,9 +1873,9 @@
}
},
"node_modules/nodemon": {
"version": "3.1.4",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.4.tgz",
"integrity": "sha512-wjPBbFhtpJwmIeY2yP7QF+UKzPfltVGtfce1g/bB15/8vCGZj8uxD62b/b9M9/WVgme0NZudpownKN+c0plXlQ==",
"version": "3.1.7",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.7.tgz",
"integrity": "sha512-hLj7fuMow6f0lbB0cD14Lz2xNjwsyruH251Pk4t/yIitCFJbmY1myuLlHm/q06aST4jg6EgAh74PIBBrRqpVAQ==",
"dev": true,
"license": "MIT",
"dependencies": {

View File

@@ -38,7 +38,7 @@
</div>
<label for="cardContent">Card Content:</label>
<input type="text" id="cardContent" name="cardContent" required>
<textarea type="text" id="cardContent" name="cardContent" required></textarea>
<label for="article">Content:</label>
<textarea id="article" name="article" rows="24" cols="80"></textarea>
@@ -58,17 +58,26 @@
</div>
<div>
<h3>Preview</h3>
<div id="preview"></div>
<h4>Card Content</h4>
<div id="preview-card-content"></div>
<h4>Article</h4>
<div id="preview-article"></div>
</div>
</div>
<script>
const markdownPreivew = document.getElementById('preview');
const markdownPreview = document.getElementById('preview-article');
const cardContentPreview = document.getElementById('preview-card-content');
const articleEditor = document.getElementById('article');
const cardContentInput = document.getElementById('cardContent');
const submitButton = document.getElementById('submit-button');
articleEditor.addEventListener('input', () => {
markdownPreivew.innerHTML = marked.parse(articleEditor.value);
markdownPreview.innerHTML = marked.parse(articleEditor.value);
});
cardContentInput.addEventListener('input', () => {
cardContentPreview.innerHTML = marked.parse(cardContentInput.value);
});
submitButton.addEventListener('click', () => {

View File

@@ -39,7 +39,7 @@
</div>
<label for="cardContent">Card Content:</label>
<input type="text" id="cardContent" name="cardContent" required>
<textarea rows="3" cols="80" id="cardContent" name="cardContent" required></textarea>
<label for="article">Content:</label>
<textarea id="article" name="article" rows="24" cols="80"></textarea>
@@ -60,13 +60,17 @@
</form>
</div>
<div>
<h3>Preview</h3>
<div id="preview"></div>
<h3>Previews</h3>
<h4>Card Content</h4>
<div id="preview-card-content"></div>
<h4>Article</h4>
<div id="preview-article"></div>
</div>
</div>
<script>
const markdownPreivew = document.getElementById('preview');
const markdownPreview = document.getElementById('preview-article');
const cardContentPreview = document.getElementById('preview-card-content');
const articleEditor = document.getElementById('article');
const submitButton = document.getElementById('submit-button');
const cardContentInput = document.getElementById('cardContent');
@@ -85,7 +89,7 @@
coverImagePathInput.value = response.data.coverImagePath;
linkPathInput.value = response.data.linkPath.split('/')[2];
articleEditor.value = response.data.article;
markdownPreivew.innerHTML = marked.parse(articleEditor.value);
markdownPreview.innerHTML = marked.parse(articleEditor.value);
if (response.data.entryType == 0) {
entryTypeArticleInput.checked = true;
} else if (response.data.entryType == 1) {
@@ -95,7 +99,11 @@
.catch((err) => {console.error(err)});
articleEditor.addEventListener('input', () => {
markdownPreivew.innerHTML = marked.parse(articleEditor.value);
markdownPreview.innerHTML = marked.parse(articleEditor.value);
});
cardContentInput.addEventListener('input', () => {
cardContentPreview.innerHTML = marked.parse(cardContentInput.value);
});
submitButton.addEventListener('click', () => {