Skip to content

Commit b17f9c0

Browse files
author
Invers3
committed
update posts
testing
1 parent 770bdf0 commit b17f9c0

File tree

8 files changed

+16158
-34
lines changed

8 files changed

+16158
-34
lines changed

.env

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Generate lastposts.json
2+
3+
on:
4+
push:
5+
paths:
6+
- '_posts/**' # Solo se ejecuta cuando hay cambios en esta carpeta
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Check out repository
14+
uses: actions/checkout@v2
15+
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v2
18+
with:
19+
node-version: '20' # Asegúrate de que tu versión de Node.js sea compatible
20+
21+
- name: Install dependencies
22+
run: npm install
23+
24+
- name: Generate lastposts.json
25+
run: node generateLastPosts.js
26+
27+
- name: Commit lastposts.json
28+
run: |
29+
git config --global user.email "manyandacreaty@gmail.com"
30+
git config --global user.name "CodeInvers3"
31+
git add lastposts.json
32+
git commit -m "Update lastposts.json"
33+
git push
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

netlify/functions/_posts/post.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

netlify/functions/hello.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,8 @@ exports.handler = async event => {
55
const subject = event.queryStringParameters.name || 'World'
66

77
var html = ''
8-
9-
const recursive = function(dirname){
10-
var acom = ''
11-
const datalist = fs.readdirSync(dirname)
12-
datalist.forEach(function(file){
13-
acom += file + "\n"
14-
})
15-
return acom
16-
}
17-
html = recursive('/var/task')
8+
9+
html = recursive('/var/task')
1810

1911
return {
2012
statusCode: 200,

netlify/functions/post.js

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,12 @@ exports.handler = async function(event){
77

88
const subject = event.queryStringParameters.name || 'post'
99

10-
const pathPost = path.join(__dirname,'_posts', subject + '.json')
11-
//const content = fs.readFileSync(pathPost)
12-
13-
var html = ''
14-
15-
const recursive = function(dirname){
16-
var acom = ''
17-
const datalist = fs.readdirSync(dirname)
18-
datalist.forEach(function(file){
19-
acom += file + "\n"
20-
})
21-
return acom
22-
}
23-
24-
html = recursive('/var')+"\n"
25-
html += recursive('/var/task')
10+
const pathPost = path.join(__dirname, 'posts.json')
11+
const content = fs.readFileSync(pathPost)
2612

2713
return {
2814
statusCode: 200,
29-
body: html
15+
body: JSON.stringify(JSON.parse(content))
3016
};
3117

3218
} catch (error) {

netlify/functions/posts.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"id": "Lastposts"
3+
}

0 commit comments

Comments
 (0)