Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generateWiki.js #1816

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ last_update:
author: ShuishengPeng
---

# reComputer R1000 use bacnet MS/TP

## Introduction
BACnet MS/TP (Master-Slave/Token Passing) is a communication protocol for building automation and control networks. It is part of the BACnet (Building Automation and Control Networks) protocol suite. MS/TP usually uses the RS-485 physical layer and bus topology. All devices are connected to the same twisted pair cable. There are master stations and slave stations in the MS/TP network. The master is responsible for generating and delivering the token, while the slave only responds when a request is received. The master device determines which device can send data by passing the token. The token passing mechanism ensures that communication on the bus is orderly and conflict-free

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ last_update:
author: Evelyn Chen
---

# **Configuring Wio-SX1262 with XIAO ESP32S3 kit as LoRaWAN Sensor Node**
# Configuring Wio-SX1262 with XIAO ESP32S3 kit as LoRaWAN Sensor Node

## Introduction

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ last_update:
author: Evelyn Chen
---

# Wio-SX1262 with XIAO ESP32S3 Kit Connect to Chirpstack

<p style={{textAlign: 'center'}}><img src="https://files.seeedstudio.com/wiki/XIAO_ESP32S3_for_Meshtastic_LoRa/51.png" alt="pir" width={900} height="auto" /></p>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ last_update:
---


# Task Assignment Guideline
# SenseCAP Watcher Task Assignment Guideline

<div style={{textAlign:'center'}}><img src="https://files.seeedstudio.com/wiki/watcher_getting_started/85.png" style={{width:1000, height:'auto'}}/></div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Hardware components of the SenseCAP Watcher.
title: Hardware overview
title: Hardware Overview
image: https://files.seeedstudio.com/wiki/watcher_getting_started/hardware_overview.jpg
slug: /watcher_hardware_overview
sidebar_position: 1
Expand All @@ -9,6 +9,8 @@ last_update:
author: Citric, Djair
---

# SenseCAP Watcher Hardware Overview

<div style={{textAlign:'center'}}><img src="https://files.seeedstudio.com/wiki/watcher_getting_started/hardware_overview.jpg" style={{width:1000, height:'auto'}}/></div>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ last_update:
author: Citric
---

# SenseCAP Watcher Operation Guideline

<div style={{textAlign:'center'}}><img src="https://files.seeedstudio.com/wiki/watcher_getting_started/0.JPG" style={{width:800, height:'auto'}}/></div>

<div class="get_one_now_container" style={{textAlign: 'center'}}>
Expand Down
25 changes: 23 additions & 2 deletions generateWiki.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,41 @@ const docsDirectory = path.join(__dirname, 'docs')
const wikiFilePath = path.join(__dirname, '/src/utils/wiki.js')

const docList = []
const excludedPaths = [
path.join(docsDirectory, 'Seeed_Elderly', 'weekly_wiki'), // 排除的目录
path.join(docsDirectory, 'weekly_wiki.md') // 排除的文件
];

// 递归函数,用于遍历多层文件夹
function processDirectory(directory) {

// 如果当前目录是要排除的路径,则跳过
if (excludedPaths.includes(directory)) {
return;
}



fs.readdirSync(directory).forEach((file) => {
const filePath = path.join(directory, file)
const fileStats = fs.statSync(filePath)

// 如果文件或文件夹在排除列表中,则跳过
if (excludedPaths.includes(filePath)) {
return;
}

if (fileStats.isDirectory()) {
// 如果是文件夹,则递归处理
processDirectory(filePath)
} else if (fileStats.isFile() && path.extname(file) === '.md') {
// 如果是 Markdown 文件
const fileContents = fs.readFileSync(filePath, 'utf-8')
const { data } = matter(fileContents)
const { data, content } = matter(fileContents)

// 优先查找第一个一级标题(以 # 开头的行)
const titleMatch = content.match(/^#\s+(.*)/m);
const title = titleMatch ? titleMatch[1].trim() : (data.title || '');

// 判断是否有 date 字段
if (data.last_update && data.last_update.date) {
Expand All @@ -28,7 +49,7 @@ function processDirectory(directory) {
docList.push({
path: slug,
image: data.image || '',
title: data.title || '',
title: title,
date: data.last_update.date,
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/home/lasted.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function IndexLatestedViki() {
// 按日期排序,假设每个文档都有 `date` 属性
const sortedDocs = flattenedDocs.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());

// 截取前 10 个文档
// 截取前 12 个文档
const topDocs = sortedDocs.slice(0, 12);

// 将文档按每两个分成一组
Expand Down Expand Up @@ -96,7 +96,7 @@ function IndexLatestedViki() {
<div className={css.wiki_group}>
{group.map((doc, subIndex) => (
<a className={css.wiki_item} href={doc.path} key={subIndex}>
<img src={doc.image} alt={doc.title} />
<img src={doc.image} alt={doc.title} style={{ maxWidth: '210px', height: '160px' }} />
<div className={css.wiki_name}>{doc.title}</div>
</a>
))}
Expand Down
Loading
Loading